Home > Blockchain >  Angular use property binding in property binding
Angular use property binding in property binding

Time:04-12

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>

CodePudding user response:

You can use:

<p *ngFor="let cIC of this.customerInformation">
  {{ cIC[language] }}
</p>

or

<p *ngFor="let cIC of this.customerInformation">
  {{ cIC?.language }}
</p>

CodePudding user response:

Use key accessor

<p *ngFor="let cIC of this.customerInformation">
  {{ cIC[language] }}
</p>
  • Related