I'm a newbie in angularjs so I tried to create my first simple application. I want to create dynamic radio buttons from json(at this point everything works fine), so I tried to bind the radio buttons with a new model to grab their values, but I don't understand how to bind a model from variables. This is my code:
<div ng-controller="TestCtrl">
<h1> {{corso._name}}</h1>
<div ng-repeat="(key,value) in corso._domande">
<h3>{{value._domanda}}</h3>
<form name="value._id" ng-repeat="ris in value._risposte">
/*I wanto to use somothing like result.key*/
<input type="{{value._type}}" ng-model="?????????" />
{{ris}}
</form>
</div>
</div>
and js:
function TestCtrl($scope) {
$scope.result={};
$scope.corso={
"_name":"Corso X",
"_domande":{
"1":{ "_domanda" : "Che colore ha la birra?",
"_id":"1",
"_type":"radio",
"_risposte" : ["giallo","rosso","blu"],
"_risportaEsatta" : "giallo"
},
"2":{ "_domanda" : "Che colore ha l'acqua?",
"_id":"2",
"_type":"checkbox",
"_risposte" : ["giallo","rosso","blu"],
"_risportaEsatta" : "giallo"
}
}
};
};