저는 초보자입니다. 두 개의 div 요소를 만들고 각도 js 프로그램을 실행하려고 할 때 몇 가지 각도 js 예제를 시도하고 있습니다. 초기화 된 배열이 두 번째 div에 인쇄되고 ng-repeat를 사용할 때 첫 번째 div에 대해 인쇄되지 않습니다. 아무도 그것이 왜 일어나고 있는지 말해 줄 수는 없어요. 나는 2 개의 배열이 초기화 된 방법 사이에 어떤 차이점을 볼 수 없다. 코드는 다음과 같습니다. 당신이 당신의 콘솔 첫 번째 ng-repeat
에 중복에 대한 오류를 볼 수에 보면Angular js가 ng-repeat를 사용하여 ng-init의 데이터를 인쇄하지 않습니다.
<html data-ng-app>
<head>
<title>Angular js</title>
</head>
<body>
<input type="text" data-ng-model="name">{{name}}
<div class="container" data-ng-init="namess=['Hello','There','God','There']">
<h3>Looping with the ng-repeat Directive</h3>
<h4>Data to loop through is initialized using ng-init</h4>
<ul>
<li data-ng-repeat="Personname in namess">{{Personname}}</li>
</ul>
</div>
<div class="container" data-ng-init="names=['Dave','Napur','Heedy','Shriva']">
<h3>Looping with the ng-repeat Directive</h3>
<h4>Data to loop through is initialized using ng-init</h4>
<ul>
<li data-ng-repeat="name in names">{{name}}</li>
</ul>
</div>
</body>
<footer>
<script type="text/javascript" src="angular.min.js"></script>
</footer>
</html>
내가 얻고 그 결과
Looping with the ng-repeat Directive
Data to loop through is initialized using ng-init
Looping with the ng-repeat Directive
Data to loop through is initialized using ng-init
Dave
Napur
Heedy
Shriva
. http://jsfiddle.net/cysa0cah/1/ – Nick