我是angularjs的新手,并试图找到一个解决方案,将选定的电台组值设置为ngmodel。收音机组选择的选项不更新角度的ngModel值
//my.html
<div ng-controller='controller'>
<div class="btn-group" ng-model="option" ng-repeat="arr in dragDropOption">
<input type="radio" name="optionCorrectOpt" data-ng-model="option"
value="{{dragDropOption[$index].text}}">
{{dragDropOption[$index].text}}
</div>
和 //mycontroller.js
app = angular.module('app', []);
app.controller('controller', function ($scope) {
$scope.dragDropOption = [];
$scope.option = "not set";
$scope.dragDropOption = [{
text: "analog"
}, {
text: "isdn"
}, {
text: "dsl"
}];
// $scope.option = $scope.dragDropOption[0].text;
});
可能是重复的问题,请帮我分享已经回答了的stackoverflow问题的链接或新的答案。提前致谢。
你'arr'内循环,所以为什么用'dragDropOption [$指数]'? – Yoshi
@Yoshi它是“arr.text”,而不是“dragDropOption [$ index] .text”这是在小提琴上调试代码。 –