//先定義一個(gè)數(shù)組
anular代碼:
var app = angular.module('serApp', []); app.controller('indexCtrl', function($scope, $http) { $scope.arrs = [{<BR> n:'a'; arr:['1','2','1'] },{<BR><BR> n:'b'; arr:['4','5','6'] }]; }) html 代碼:
<BR> <div ng-controller="indexCtrl"><BR> <p>{{name}}</p><BR> <ul><BR> <li ng-repeat="name in names">{{name.n}}<BR> <p ng-repeat="a in name.arr track by $index" id="{{$index}}">{{a}}</p><BR> </li><BR> </ul><BR> </div><BR><BR> track by $index 在有重復(fù)值時(shí)需加上這段代碼 不然瀏覽器會(huì)報(bào)這個(gè)錯(cuò) Error: [ngRepeat:dupes]并且不會(huì)渲染到頁面
以上這篇angular ng-repeat數(shù)組中的數(shù)組實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持武林網(wǎng)。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注