gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 18:05:29 25 4
gpt4 key购买 nike

我在 angularjs 中有一个问题。

在我的 Controller 中,我有一个逗号分隔的字符串,我将在我的 index.html(with ng-repeat) 中显示它

这是我的 Controller :

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(',');
});

这是我的 html:
<div ng-controller="TabsDemoCtrl">
<td ng-repeat="icerik in arrString">
{{icerik}}
</td>
</div>

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

最佳答案

这是plunker为你

您需要通过 $index 使用 track ,因为它在数组中有重复的值。

ng-repeat="icerik in arrString track by $index"

关于angularjs - 用于逗号分隔字符串的 Angular ng-repeat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29487596/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com