gpt4 book ai didi

javascript - 如何使用 ng-repeat

转载 作者:行者123 更新时间:2023-12-02 17:11:54 25 4
gpt4 key购买 nike

我想对以下数据使用 ng-repeat:

{"data":[{"id":1,"namn":"Bryan","efternamn":"Karlsson"},{"id":2,"namn":"Kalle","efternamn":"Kula"},{"id":3,"namn":"Fisk","efternamn":"Fisksson"},{"id":4,"namn":"Daniel","efternamn":"Fisksson"}]}

我尝试像这样使用它:

<div ng-controller="Test">
<tr ng-repeat="namn in test">
<td>{{namn}}</td>
</tr>
</div>

我不知道为什么。是因为 JSON 字符串中的“数据”吗?

这是我的 Controller :

as.controller('Test', function($scope, $http, $rootScope)
{
$http.get($rootScope.appUrl + '/nao/test/test')
.success(function(data, status, headers, config) {
$scope.test = data;
});
});

最佳答案

<div ng-controller="Test">
<tr ng-repeat="record in test.data">
<td>{{record.namn}}</td>
</tr>
</div>

关于javascript - 如何使用 ng-repeat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24752450/

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