2016-09-19 3 views
0

cList의 각 항목을 표시하려고하지만 작동하지 않습니다. div 태그의 정확한 수를 만듭니다 (ng-repeat로부터). 그러나 비어 있습니다. 그것은 항목이 정의되지 않은 것처럼 보이므로 아무 것도 나타나지 않습니다. 나는에 다른 것을 넣으면angularjs ng-repeat item is undefined

<div ng-repeat="item in cList" class="ng-scope"> 

</div> 
<!-- end ngRepeat: item in cList --> 

:

<div ng-controller="listController"> 
    <div ng-repeat="item in cList"> 
    {{item}} 
    </div> 
</div> 

그것은이 HTML 5 번 반복 생산 :

var app = angular.module('MyApp'); 

app.controller('listController', function($scope) { 
    $scope.cList = [ 'c1', 'c2', 'c3', 'c4', 'c5' ]; 
}); 

이것은 HTML은 다음과 같습니다

컨트롤러입니다 ng-repeat의 div 태그는 페이지에 5 번 표시됩니다. 항목이 정의되지 않은 이유가 있습니까?

+0

으로 아래의 코드를

 var app = angular.module('MyApp'); 

를 교체해야, 모듈에 빈 종속 배열을 추가 대답? – Sajeetharan

+0

@sajeetharan 문제를 해결하지 못했습니다. 프로젝트가 설정되는 방식에 문제가 될 수 있습니까? – Neil

+0

나에게 팀 뷰어를 줄 수 있습니까? – Sajeetharan

답변

1

var app = angular.module("MyApp", []); 

<body ng-app='myApp' > 
    <div ng-controller="listController"> 
    <div ng-repeat="item in cList"> 
     {{item}} 
    </div> 
    </div> 
    </body> 

WORKING DEMO

0

당신은 당신이를 확인 않았다이

var app = angular.module('MyApp',[]);