给定此控制器和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.");
});
};