Am new to angular js. I have the following code
<div ng-controller="myCtl">
<input type='checkbox' ng-model='selectAll'/>Select All
<div ng-repeat="c in language.availableOptions">
<input type='checkbox' ng-model='language.opted[$index]'
ng-checked="selectAll" ng-true-value='{{c}}'
ng-false-value=""/>
{{c}}
</div>
{{selectAll}}
selected languages : {{language.opted}}
</div>
<script type="text/javascript">
/**
* Module
*
* Description
*/
var myApp = angular.module('myApp', []);
myApp.controller('myCtl', ['$scope', function($scope) {
$scope.language ={};
$scope.language.availableOptions = ["java","c","cpp","asp"];
$scope.language.opted=[];
$scope.selectAll=false;
}])
</script>
The idea is that if user selects select all then all languages will be selected and update corresponding model [language.opted].
Now if I select 'select all' check box all checbox are selected, but the model is empty. why?
Aucun commentaire:
Enregistrer un commentaire