javascript - angularjs, bug in nested array with same value -
javascript - angularjs, bug in nested array with same value -
i've tried lastly 2 days on little problem.
i'm new on angularjs, , don't understand why not working.
if there same value in array, nested ng-repeat doesn't work :(
is can help me please ?
index.html :
<!doctype html> <html ng-app="testapp"> <head> <title></title> </head> <body ng-controller="testctrl"> <ul> <li ng-repeat="item in items"> {{item.ip}} <ul> <li ng-repeat="s in item.status">{{s}}</li> </ul> </li> </ul> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script> <script src="app.js"></script> </body> </html>
app.js (this working)
var app = angular.module('testapp', []); app.controller('testctrl', function ($scope) { $scope.items = [ {ip: '192.168.1.23', status: ['aaa','bbb','ccc','ddd','eee','fff']}, {ip: '192.168.1.24', status: ['ggg','hhh','iii','jjj','kkk','lll']} ]; });
app.js (doesn't work)
var app = angular.module('testapp', []); app.controller('testctrl', function ($scope) { $scope.items = [ {ip: '192.168.1.23', status: ['na','up','na','down','down','na']}, {ip: '192.168.1.24', status: ['up','down','na','up','up','na']} ]; });
thanks lot
you have utilize track by
look tell angular elements different. try
<ul> <li ng-repeat="item in items"> {{item.ip}} <ul> <li ng-repeat="s in item.status track $index">{{s}}</li> </ul> </li> </ul>
javascript arrays angularjs
Comments
Post a Comment