Arnaud Denoyelle
Arnaud Denoyelle

Reputation: 31225

Prevent angular from creating unecessary dom element

I defined a footer : <app-footer></app-footer>

The app-footer template is : <footer>[...]</footer>

Hence, the generated DOM is : <app-footer><footer>[...]</footer></app-footer>

I want to keep app-footer in the code but I don't want it in the DOM. i.e. I want the DOM to only contain <footer>[...]</footer>.

How do I achieve that?

Upvotes: 1

Views: 463

Answers (1)

user184994
user184994

Reputation: 18281

You could always change your selector from app-footer to [app-footer], so that it becomes an attribute selector.

Then, when you want to use it, instead of <app-footer></app-footer> you can do <footer app-footer></footer>

Then, just remove the footer tag from your app-footer.component.html file

Upvotes: 1

Related Questions