Here is my code:
<body ng-app="app">
<div ng-controller="TestController">
<input type="checkbox" checked ng-repeat="num in array track by $index" ng-model="array[$index]" />
</div>
<script type="text/javascript">
var app = angular.module('app', []);
app.controller('TestController', function ($scope) {
$scope.array = [1, 2, 3, 4];
});
</script>
I especially add checked
attribute to each <input>
tag, for the checkbox could checked by default. But the result is none of the four checkbox is checked. Why?
I know if I add ng-checked="num"
attribute could make the checked work, But I still wondering why the natural checked arrtibute doesn't work.
Aucun commentaire:
Enregistrer un commentaire