Nooka10 Nooka10 - 4 months ago 24
AngularJS Question

double data-binding in AngularJS

Is it possible to make a "double data-binding" with angularJS ?

I want to get

mat.Discipline[0].nom_FR
in an array that have
nom_FR
,
nom_DE
,
nom_EN
and
nom_IT
.

mat.Langue[0].langue
give me "FR", "DE", "EN" or "IT" depending what language the user choose.

So I would like to use
{{mat.Langue[0].langue}}
to determine if the discipline should be
nom_FR
,
nom_DE
or another...

I try to do something like that:
{{mat.Discipline[0].nom_{{mat.Langue[0].langue}}}}
but of course, it doesn't work...

Do you have an idea ?
Thanks a lot!

Answer

Use square brackets notation:

{{mat.Discipline[0]["nom_" + mat.Langue[0].langue]}};