cari

Rumah  >  Soal Jawab  >  teks badan

angular.js - ngReapeat循环的标签如何命名ID

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script> 
</head>
<body>

<p ng-app="" ng-init="names=[
{name:'Jani',country:'Norway'},
{name:'Hege',country:'Sweden'},
{name:'Kai',country:'Denmark'}]">

<p>循环对象:</p>
<ul>
  <li ng-repeat="x in names" id="'name'+$index" >
  {{ x.name + ', ' + x.country }}</li>
</ul>

</p>

</body>
</html>

想要id是name0、name1、name2,结果原封不动

PHP中文网PHP中文网2745 hari yang lalu583

membalas semua(1)saya akan balas

  • PHP中文网

    PHP中文网2017-05-15 17:04:35

    Tulis ini:

    <ul>
      <li ng-repeat="x in names" id="{{ 'name' + $index }}" >
      {{ x.name + ', ' + x.country }}</li>
    </ul>

    balas
    0
  • Batalbalas