Categories
Angular Answers

How to render a component without its wrapping tag with Angular?

Spread the love

Sometimes, we want to render a component without its wrapping tag with Angular.

In this article, we’ll look at how to render a component without its wrapping tag with Angular.

How to render a component without its wrapping tag with Angular?

To render a component without its wrapping tag with Angular, we can use attribute selectors.

For instance, we write

@Component({
  selector: "[myTd]",
  //...
})
export class ChildComponent {
  //...
}

to set the selector of the component to '[myTd]'.

Then in the parent component, we add

<td myTd></td>

to render the content of ChildComponent in the td element.

Conclusion

To render a component without its wrapping tag with Angular, we can use attribute selectors.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *