Reputation: 169
This is my controller
mode.controller("array_l",['$scope',function($scope){
$scope.items=[1,2,3,4,5];
//console.log( $scope.items);
}]);
This is my HTML
<div ng-controller="array_l" ng-repeat="item in items">
{{item}}
</div>
ng-repeat not showing any value given controller and html
Upvotes: 0
Views: 860
Reputation: 2954
Move your ng-controller
directive before your ng-repeat
block.
Use track by $index
in your ng-repeat
to avoid problems with duplicate elements.
angular.module('mode',[])
.controller("array_l",['$scope',function($scope){
$scope.items=[1,2,3,1];
}]);
HTML:
<div ng-app="mode" ng-controller="array_l">
<div ng-repeat="item in items track by $index">
{{item}}
</div>
</div>
Upvotes: 1
Reputation: 41
<div ng-repeat="item in items">
{{item}}
</div>
Defiantly worth reading through the Angular docs.
Upvotes: 0