Reputation: 3188
How can I get the text content from the component selector?
As an example:
<div class="page-wrapper">
<app-page-title>List applications</app-page-title>
<router-outlet></router-outlet>
</div>
I have the app-page-title
component, but I do not understand, how I can get the value of this node ("List applications") in my component.
UPD:
<app-card>
<app-card-title>Some My Title</app-card-title>
<app-card-content>Some My Content</app-card-content>
<app-card-footer>Some My Footer</app-card-footer>
</app-card>
How can I get the inner nodes from app-card
component?
Upvotes: 0
Views: 424
Reputation: 4176
The easiest way to do it, would be to set the title in your component and then interpolate that into your view. For instance.
<div class="page-wrapper">
<app-page-title>{{myPageTitle}}</app-page-title>
<router-outlet></router-outlet>
</div>
And then in your component typescript, it would be something like:
@Component({...})
export class pageTitleComponent {
...
myPageTitle = 'List applications'
}
Upvotes: 1
Reputation: 60578
Is it possible to rewrite it like this:
<div class="page-wrapper">
<app-page-title text="List applications"></app-page-title>
<router-outlet></router-outlet>
</div>
If so, then you can define an input property in the app-page-title (child) component using the input decorator. Then the child component has the value in that property.
@Input() text: string;
Upvotes: 0