加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 角度智能表在更新时不刷新

发布时间:2020-12-17 16:56:01 所属栏目:安全 来源:网络整理
导读:给定此控制器和html,将调用刷新回发,但即使使用数据,表也不会更新.无法解决原因. angular.module('umbraco').requires.push('smart-table');app.controller('adminSection.manageUsersController',[ '$scope','$http','dialogService',function ($scope,$htt
给定此控制器和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.");
        });
    };

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读