Angular JS: Input[radio] Doesn't Work
Here is my code:
&l
Solution 1:
ng-repeat create new scope so you should determine parent scope.
for more info see https://docs.angularjs.org/api/ng/directive/ngRepeat
var app = angular.module('app', []);
app.controller('TestController', function ($scope) {
$scope.array = [{
name: 'lee',
seq: 1,
}, {
name: 'tom',
seq: 2,
}, {
name: 'jack',
seq: 3,
}];
$scope.selected = $scope.array[0].name;
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller="TestController">
<div ng-repeat="item in array">
<input type="radio" ng-model="$parent.selected"
ng-value="item.name" >
</div>
</div>
Post a Comment for "Angular JS: Input[radio] Doesn't Work"