问题描述:

I have receive listof objects with names: F1,F2,F3,F4

when I make call to server, I receive new list F1,F2,F3,F5,F4

when I apdate ng-repeat list:

vm.folders = data.content.items;

it shows next list: F1,F2,F3,F4,F4

where am I wrong? here is my html code:

<div ng-repeat="folder in vm.folders track by $index" ng-init="openInput=false;">

<div layout="row" ng-init="folderName = vm.getIterationName(folder.metadata)" >

<div >

</div>

<div >

<span ng-click="showChildren[$index]=!showChildren[$index]" class="capitalize" ng-dblclick="openInput = true;$event.stopPropagation();" ng-show="!openInput">{{folderName}}</span>

</div>

</div>

</div>

js update method:

 function updateIterations(data) {

if (data.ok === true) {

if(angular.toJson(vm.folders) != angular.toJson(data.content.items)) {

vm.folders = data.content.items;

}

} else if (data.ok == false) {

console.log ('Error:iteration request: {ok: false}');

$interval.cancel(intervalRequests);

}

}

网友答案:

fixed! in

<span ng-click="showChildren[$index]=!showChildren[$index]" class="capitalize"  ng-dblclick="openInput = true;$event.stopPropagation();" ng-show="!openInput">{{folderName}}</span>

instead of {{folderName}} i've used:

<span ng-click="showChildren[$index]=!showChildren[$index]" class="capitalize"  ng-dblclick="openInput = true;$event.stopPropagation();" ng-show="!openInput">{{vm.getIterationName(folder.metadata)}}</span>
相关阅读:
Top