Angular 4 components -
i new angular 4.
i have doubt in angular 4 embedded components.
example:
<hero-list> <hero></hero> <hero></hero> </hero-list> i wanted know how create view based on structure embedding component inside component.
you should use <ng-content></ng-content> in hero-list-component. can realize wish above.
hero-list.component.html
<div class="hero-list"> <h1>hero list</h1> <ng-content></ng-content> </div> and can wrap hero-item-components , printed inside of hero-listcomponent.
app.component.html
<hero-list> <hero-item></hero-item> <hero-item></hero-item> </hero-list> here working example: https://stackblitz.com/edit/angular-nvpmtc
and here article content projection in angualr.
Comments
Post a Comment