ngOptions vs ngRepeat
by M. Junaid Salaat
HTML
<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div ng-controller="MyCtrl">
<table>
<tr ng-repeat="source in reasons">
<td>{{source.sourceName}}</td>
<td>
<input type="checkbox" ng-model="source.postAdequate" ng-change="changeDet()">
</td>
</tr>
</table>
</div>
JavaScript
var myApp = angular.module('myApp', []);
//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});
function MyCtrl($scope) {
$scope.reasons = [{
sourceName: 'Lack of rainfall'
}, {
sourceName: 'Change in land use'
}, {
sourceName: 'Change in Land Cover'
}];
$scope.changeDet = function() {
console.log($scope.reasons);
}
}