'Angular use property binding in property binding
I wanna use a property, in this case a string, to get an attribute of an object.
I thought of something like this:
cIC -> Object with attribute nameDe
language -> String with nameDe
<p *ngFor="let cIC of this.customerInformation">
{{ cIC.{{ language }} }}
</p>
Solution 1:[1]
You can use:
<p *ngFor="let cIC of this.customerInformation">
{{ cIC[language] }}
</p>
or
<p *ngFor="let cIC of this.customerInformation">
{{ cIC?.language }}
</p>
Solution 2:[2]
Use key accessor
<p *ngFor="let cIC of this.customerInformation">
{{ cIC[language] }}
</p>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ahmad Habib |
| Solution 2 | Antoniossss |
