gpt4 book ai didi

angularjs - Angular 智能表在更新时不刷新

转载 作者:行者123 更新时间:2023-12-01 04:58:23 25 4
gpt4 key购买 nike

给定这个 Controller 和 html,刷新回发被调用,但即使有数据,表也不会更新。无法弄清楚为什么。

angular.module('umbraco').requires.push('smart-table');
app.controller('adminSection.manageUsersController', [
'$scope', '$http', 'dialogService', function ($scope, $http, dialogService) {
var ctrl = this;
ctrl.members = [];
ctrl.safeMembers = [];
ctrl.fetchResults = function fetchResults(tableState) {
$http.post('/umbraco/backoffice/api/members/search', tableState.search.predicateObject || {codeId: null}).then(function (response) {
ctrl.members = response.data;
ctrl.safeMembers = [].concat(ctrl.members);
console.log(ctrl.safeMembers);
}, function (response) {
console.log(response);
alert("There was an error in the CODE back office app.");
});
};

}
]);

<div class="umb-pane" ng-controller="adminSection.manageUsersController as mc">
<table st-pipe="mc.fetchResults" st-table="mc.members" st-safe-src="mc.safeMembers" class="table table-striped">
<thead>
<tr>
<th st-sort="codeId">Id</th>
<th>Name / Job Title / Email</th>
<th>Access Granted</th>
</tr>
<tr>
<th>
<input st-search="codeId" placeholder="search code id"/>
</th>
<th><input st-search="name" placeholder="search name"/> ( <input st-search="email" placeholder="search email"/> ) of <input st-search="employer" placeholder="search employer"/></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody >
<tr ng-repeat="member in mc.safeMembers">
<td>{{member.codeId}}</td>
<td>{{member.fullname}} / {{member.employer}} / {{member.email}}</td>
<td>{{member.codeId}}</td>
</tr>
</tbody>
</table>
</div>

我遵循了这个例子: link to docs

最佳答案

您的转发器应该在显示的集合中(即成员)

<tr ng-repeat="member in mc.members">

获取数据时无需更新显示的集合
        ctrl.fetchResults = function fetchResults(tableState) {
$http.post('/umbraco/backoffice/api/members/search', tableState.search.predicateObject || {codeId: null}).then(function (response) {
ctrl.safeMembers = response.data;
}, function (response) {
console.log(response);
alert("There was an error in the CODE back office app.");
});
};

关于angularjs - Angular 智能表在更新时不刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35115204/

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