Skip to content Skip to sidebar Skip to footer

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;
    });
<scriptsrc="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script><divng-app="app"ng-controller="TestController"><divng-repeat="item in array"><inputtype="radio"ng-model="$parent.selected"ng-value="item.name" ></div></div>

Post a Comment for "Angular Js: Input[radio] Doesn't Work"