Reputation: 47881
I see from the docs that you can use @input to pass a property value to the component.
However how can you pass the innerText to the component so that one can do something like this?
<error-label>this is required"</error-label>
and pass the inner text to the component.
Upvotes: 2
Views: 1573
Reputation: 657406
You can use a tempalte variable to create a reference and access it from within the template
<div #myDiv>foo</div>
<button (click)="sendInnerText(myDiv.innerText)">pass inner text</div>
or the component
@ViewChild('myDiv') divRef:ElementRef;
ngAfterViewInit() {
console.log(this.div.nativeElement.innerText);
}
Upvotes: 2