Reputation: 5948
I have a component on which I specify the angular i18in attribute like this:
<app-text i18n="meaning|description"> DeveloperText</app-text>
I want to be able to read this property. I have tried using ElementRef and accessing nativeElement but the attribute i18n is not a part of the DOM element when I view the source. When my app is launched the DOM looks like this:
<app-text _ngcontent-c0=""> DeveloperText</app-text>
So can I somehow read properties like this using the Angular Framework?
Upvotes: 1
Views: 187
Reputation: 57116
In your HTML:
<app-text #something i18n="meaning|description">DeveloperText</app-text>
In your controller:
@ViewChild('something') fred;
You now have a handle on the element. If you log it like this:
console.log(this.fred);
console.log(this.fred.nativeElement);
You should find the value of the property you are interested in.
Upvotes: 1