gpt4 book ai didi

javascript - 从 json 获取值到 angularjs 对象

转载 作者:行者123 更新时间:2023-12-03 03:07:47 24 4
gpt4 key购买 nike

我想从这个 JSON 响应中获取值到 Angular js 对象中。

[{"label":"Test","value":"","Test2":"","re​​quired":"mandatory","type":"text","typeemail": “”}]

进入 angularjs 对象,这里是 .html

<tr ng-repeat="item in searched = (coba | filter:customerid | filter:search ) | coba:(currentPage-1)*itemsPerPage |limitTo:viewby ">
<td>
<p>{{item.additionaldata_pay}}</p>
</td>
</tr>

这是 .js 文件

app.controller("cobacont", ['$scope','$http',function($scope,$http) {
$scope.cari = function () {
$http.get('...a='+$scope.month).then(function(response){
$scope.coba = response.data;
});
}
}]);

最佳答案

var app = angular.module('main-App', []);
app.controller('customersCtrl', function($scope,$http) {

$scope.records = [];

$http.get("https://...a='+$scope.month")
.then(function (response) {
console.log(response.data);
$scope.records = response.data;
});
});

这是我的 html 表格

<tr dir-paginate="value in data | itemsPerPage:5" total-items="totalItems"  ng-repeat="user in records">
<td>{{$index+1}}</td>
<td >{{user.label}}</td>
<td >{{user.value}}</td>
<td>{{user.required}}</td>
<td>
<button data-toggle="modal" data-target="#edit-data" class="btn btn-primary" ng-click="selectedUser(user)">Edit</button>
<button ng-click="DeleteUser(user)" class="btn btn-danger" data-toggle="modal" data-target="#delete-data">Delete</button>
</td>
</tr>

关于javascript - 从 json 获取值到 angularjs 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47092619/

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