Is there a way to not show the component name in html in Angular 2 or higher?

This component ...

<my-component>
   <p>Hello !</p>
</my-component>

... Inside the html template ....

<div class="myClass">
   <my-component></mycomponent>
</div>

... Something similar will look on the client side:

<div class="myClass">
   <my-component>
     <p>Hello !</b>
  </mycomponent>
</div>

Are there any ways not to display the html component tag, but display the internal content of the components? Sort of...

<div class="myClass">
      <p>Hello !</b>
</div>
+4
source share
1 answer

Since you have a selector, you can try to do

<div class="myClass">
   <div my-component></div>
</div> 

Otherwise, according to this page

Directives that replace their host element (replace: true directives in Angular 1) are not supported in Angular 2. In many cases, these directives can be updated to regular component directives.

0
source

Source: https://habr.com/ru/post/1691781/


All Articles