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!
2 Answers 2
Use square brackets notation:
{{mat.Discipline[0]["nom_" + mat.Langue[0].langue]}};
2 Comments
Thanks a lot, it finally work! ^^
I use your answer, but in javascript and it work!
Here is what I do in my Javascript:
for (var i = 0; i < vm.allMateriel.length; i ++) {
var langue = vm.allMateriel[i].Langue[0].langue;
vm.allMateriel[i].Discipline[0].nom = vm.allMateriel[i].Discipline[0]['nom_' + langue];
}