用于逗号分隔字符串的Angular ng-repeat

ald*_*122 5 comma angularjs angularjs-ng-repeat

我在angularjs中有一个问题.

在我的控制器中,我有一个逗号分隔的字符串,我将在我的index.html中显示它(使用ng-repeat)

这是我的控制器:

myApp.controller('TabsDemoCtrl',function($scope,$http){
    $http.get('/performbatch').success(function(data) {
        $scope.string = 'Gzrgh,1,2,1,4,1,1,1,20150304,20180304';
        $scope.arrString = new Array();
        $scope.arrString = $scope.string.split(',');
    });
Run Code Online (Sandbox Code Playgroud)

这是我的HTML:

<div ng-controller="TabsDemoCtrl">
    <td ng-repeat="icerik in arrString">
       {{icerik}}
    </td>
</div>
Run Code Online (Sandbox Code Playgroud)

但我无法做到这一点.你能帮助我吗?提前致谢.

squ*_*oid 3

这是给你的plunker

您需要使用 $index 进行跟踪,因为它在数组中具有重复值。

ng-repeat="icerik in arrString track by $index"
Run Code Online (Sandbox Code Playgroud)