filmov
tv
Content Projection with ng-content (Tutorial 36)

Показать описание
Content Projection is one of the most useful feature of angular that helps you to build reusable components.
Sometimes the nature of a component means that the consumer would like to customise the view, the presentation of data, in a unique way for each use case.
We have learnt how to pass data from parent component to child component using @Input and @Output decorator , but that is only limited to pass data from parent to child and child to parent.
Learn about these topics which I have used in this video
ng-content is a predefined directive in angular that is used to implement content projection in angular, if we add ng-content anywhere in our template of our component, the inner content of tags that define our component are then projected on this place.
To implement multiple content projection ,select attribute can be used. You need to pass the selector name(id, class, element selector) in select attribute, then only with that template will projected to that placeholder which has that selector.
This code is available on github:
I have used below FAKE API in demo to illustrate the AsyncSubject:
Follow us on:
#contentprojection #ngcontent #nishasingla
Sometimes the nature of a component means that the consumer would like to customise the view, the presentation of data, in a unique way for each use case.
We have learnt how to pass data from parent component to child component using @Input and @Output decorator , but that is only limited to pass data from parent to child and child to parent.
Learn about these topics which I have used in this video
ng-content is a predefined directive in angular that is used to implement content projection in angular, if we add ng-content anywhere in our template of our component, the inner content of tags that define our component are then projected on this place.
To implement multiple content projection ,select attribute can be used. You need to pass the selector name(id, class, element selector) in select attribute, then only with that template will projected to that placeholder which has that selector.
This code is available on github:
I have used below FAKE API in demo to illustrate the AsyncSubject:
Follow us on:
#contentprojection #ngcontent #nishasingla
Комментарии