AngularJS 表达式
使用ng-repeat 来循环数组
<div ng-app="" ng-init="names=[‘Jani‘,‘Hege‘,‘Kai‘]"> <ul> <li ng-repeat="x in names"> {{ x }} </li> </ul> </div>
<div ng-app="" ng-init="names=[ {name:‘Jani‘,country:‘Norway‘ }, {name:‘Hege‘,country:‘Sweden‘}, {name:‘Kai‘,country:‘Denmark‘} ];countrys=[ {name:‘1‘,country:‘a‘}, {name:‘2‘,country:‘b‘}, {name:‘3‘,country:‘c‘} ]"> <p>循环对象:</p> <ul> <li ng-repeat="x in names"> {{x.name + ‘,‘ + x.country}} </li> <li ng-repeat="y in countrys"> {{y.name + ‘,‘ + y.country}} </li> </ul> </div>
时间: 2024-11-08 10:08:43