首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在angular.js中编辑后立即刷新数据表

在angular.js中编辑后立即刷新数据表
EN

Stack Overflow用户
提问于 2016-01-20 15:31:40
回答 2查看 919关注 0票数 0

我在angular.js应用程序中使用数据表。在这个更新之后,我需要在不刷新整个页面的情况下显示更新结果。只需要用新值刷新和更新表。请帮帮忙。

这是我的Controller.js

代码语言:javascript
复制
$scope.updateInternship = function() {
    $("#internshipEdit").modal('hide');
    internshipService.updateInternship(
        $scope.internship,
        function(data) {
            $rootScope.loggedInUser = data;
            $scope.internship = data;
            $growl.box(
                'Hello!',
                'Your details have been updated.',
                {
                    class : 'success',
                    sticky : false,
                    timeout : 5000
                }
            ).open();
        }
    );
}

这是显示表格的html页面。

代码语言:javascript
复制
<table datatable="ng" dt-options="dtOptions" cellspacing="0" width="100%" class="table table-striped table-hover table-bordered">
    <thead>
        <tr>
            <th>Id</th>
            <th>Title</th>
            <th>Category</th>
            <th>Status</th>
            <th>Created date</th>
            <th>Action</th>
        </tr>
    </thead>
    <tfoot>
        <tr>
            <th>Id</th>
            <th>Title</th>
            <th>Category</th>
            <th>Status</th>
            <th>Created date</th>
            <th>Action</th>
        </tr>
    </tfoot>
    <tbody>
        <tr ng-repeat="internship in allinternships">
            <td><span>{{$index+1}}</span></td>
            <td><span>{{internship.title}}</span></td>
            <td><span>{{internship.category.name}}</span></td>
            <td><span>{{internship.status}}</span></td>
            <td><span>{{internship.appliedDate | date:'d MMMM yyyy'}}</span></td>
            <td>
                <button class="btn btn-default btn-sm" data-title="Hold" data-toggle="modal" ng-click="hold(internship.id)">
                    <i class="fa fa-pause"></i>
                </button>
                <a href="javascript:;" class="btn btn-default btn-sm" data-title="Edit" data-toggle="modal" ng-click="update(internship.id)" >
                    <i class="icon bb-edit"></i>
                </a>
                <button class="btn btn-default btn-sm" data-title="View" data-toggle="modal" ng-click="deleteinternship(internship.id,$index)">
                    <i class="icon bb-trash"></i>
                </button>
                <button class="btn btn-default btn-sm" data-title="View" data-toggle="modal" ng-click="viewInternship(internship.id)">
                    <i class="icon bb-view"></i>
                </button>
            </td>
        </tr>
    </tbody>
</table>
EN

回答 2

Stack Overflow用户

发布于 2016-01-20 16:19:52

您可以尝试此解决方案:

  1. 如果您使用的是路径提供者,则可以使用

$route.reload();

  • If如果您正在使用$state provider,则可以使用

$state.reload();

抱歉,如果我误解了你的情况。

票数 0
EN

Stack Overflow用户

发布于 2016-01-20 16:39:45

请在更新数据后尝试添加$scope.$apply();

否则,请尝试:

代码语言:javascript
复制
$scope.$watch(function() {
  // Here you should return the value that changes
  return $scope.internship;
}, function() {
  // You arrive here if the returned element before has changed
  $scope.internship = data; 
});

我很难理解你所做的事情。如果有帮助,请告诉我。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34893988

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档