I am new to angular js, I am having trouble selecting default value for radio button for a c# list property,
I have fiddle link, and the code is as below,
HTML:
<div ng-controller="MyCtrl">
<p>Questions:</p>
<ul>
<li ng-repeat="question in data">
<label>{{question.QuestionDescription}}</label>
<div ng-repeat="i in question.Options">
{{i.OptionDescription}}<input type="radio" value="{{i.Id}}" name="QuestionAnswer"/>Yes
<input type="radio" value="{{i.Id}}" name="QuestionAnswer"/>No
</div>
</li>
</ul>
ANGULAR SCRIPT:
enter code herefunction MyCtrl($scope) {
$scope.data = [{
"QuestionId":1,
"QuestionDescription": "What is your fav color?",
"Options":[{"Id":1,"OptionDescription":"White","IsAnswer":true},
{"Id":2,"OptionDescription":"Black","IsAnswer":false}]
}];
}
WHAT I NEED HELP FOR:
- I want the defaults to be selected when page loads
- Data binding if the Admin changes the options