ng repeat - AngularJS - accessing a array of objects in a controller goes wrong -
i'm trying access array of objects in controller :
angular.module('schoolmanagement').controller('cyclecontroller', ['$scope', function($scope){ $scope.cycles = [ { nomcycle : 'primaire', active : 'oui' }, { nomcycle : 'collège', active : 'non' } ]; console.log($scope.cycles[0].nomcycle); }]);
the console.log() gives i'm looking in console, when use ng-repeat loop on array in view, doesn't work :
<tbody ng-controller="cyclecontroller cyclectrl"> <tr ng-repeat="cycle in cyclectrl.cycles"> <td> <input type="checkbox" /> </td> <td>{{cycle.nomcycle}}</td> <td>{{cycle.active}}</td> </tr> </tbody>
edit :
since i'm using $scope
there no need use controller syntax, correct form in :
<tr ng-repeat="cycle in cycles">...</tr>
i assume line
<tr ng-repeat="cycle in cyclectrl.cycles">
shall
<tr ng-repeat="cycle in cycles">
p.s: in french, primère spelled : primaire
Comments
Post a Comment