IT/앵귤러js

AngularJS Directives(지시문) - Repeating HTML Elements(반복되는 HTML 요소)

조원태 2017. 8. 3. 10:43
반응형

AngularJS Directives(지시문) - Repeating HTML Elements(반복되는 HTML 요소)


이 ng-repeat지시문은 HTML 요소를 반복합니다.


<div ng-app="" ng-init="names=['Jani','Hege','Kai']">

  <ul>

    <li ng-repeat="x in names">

      {{ x }}

    </li>

  </ul>

</div>


소스

<!DOCTYPE html>

<html>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>

<body>


<div ng-app="" ng-init="names=['Jani','Hege','Kai']">

  <p>Looping with ng-repeat:</p>

  <ul>

    <li ng-repeat="x in names">

      {{ x }}

    </li>

  </ul>

</div>


</body>

</html>


ng-repeat지시어는 실제로 HTML 요소를 복제합니다 콜렉션의 각 항목에 대해 한 번.


ng-repeat오브젝트의 배열에 사용 지시문 :


<div ng-app="" ng-init="names=[

{name:'Jani',country:'Norway'},

{name:'Hege',country:'Sweden'},

{name:'Kai',country:'Denmark'}]">


<ul>

  <li ng-repeat="x in names">

    {{ x.name + ', ' + x.country }}

  </li>

</ul>


</div>


소스

<!DOCTYPE html>

<html>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>

<body>


<div ng-app="" ng-init="names=[

{name:'Jani',country:'Norway'},

{name:'Hege',country:'Sweden'},

{name:'Kai',country:'Denmark'}]">


<p>Looping with objects:</p>

<ul>

  <li ng-repeat="x in names">

  {{ x.name + ', ' + x.country }}</li>

</ul>


</div>


</body>

</html>


반응형

'IT > 앵귤러js' 카테고리의 다른 글

AngularJS Controllers - Controller Methods  (0) 2017.08.06
AngularJS Controllers  (0) 2017.08.06
AngularJS Directives(지시문) - 데이터 바인딩  (0) 2017.08.03
AngularJS Directives(지시문)  (0) 2017.08.03
앵큘러JS 모듈 만들기  (0) 2017.08.02