在我的角度应用程序中,我有一个控制器如下:
function TemplateListControl($scope,TemplateService){ $scope.templates = TemplateService.get(); // Get objects from resource // Delete Method $scope.deleteTemplate = function(id){ $scope.templates.$delete({id: id}); } }
<table ng-model="templates"> <thead> <tr> <th style="width:40%">Title</th> <th style="width:40%">controls</th> </tr> <thead> <tbody> <tr ng-repeat="template in templates"> <td> <!-- Link to template details page --> <a href="#/template/[[template.id]]"> [[template.title]] </a> </td> <td> <!-- Link to template details page --> <a class="btn btn-primary btn-small" href="#/template/[[template.id]]">Edit </a> <!-- Link to delete this template --> <a class="btn btn-primary btn-small" ng-click="deleteTemplate(template.id)">Delete </a> </td> </tr> </tbody> </table>
现在当我点击上面模板中的删除链接时,它调用了deleteTemplate方法,并且对REST api进行了成功的DELETE调用.但是在刷新并且$scope.templates = TemplateService.get()之前,视图不会更新.再次发起.我究竟做错了什么?
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。