Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(Angular 2+) ng-content projection without rendering the selector container

Can <ng-content> be used in the following way?

Defining:

<th>title</th>
<ng-content select="[stuff]"></ng-content>

Using:

<div stuff>
    <th>category</th>
</div>

The HTML that gets generated doesn't include the <div stuff>:

<th>title</th>
<th>category</th>
like image 790
riyuyu Avatar asked Mar 04 '26 07:03

riyuyu


1 Answers

This can be achieved using ng-container

Replacing the <div stuff> with <ng-container stuff> should work

Example https://stackblitz.com/edit/angular-hhimgu

like image 86
Simon Hoss Avatar answered Mar 06 '26 20:03

Simon Hoss



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!