在我的角度应用程序后,认为我有一个控制器如下:
function TemplateListControl($scope, TemplateService){
$scope.templates = TemplateService.get(); // Get objects from resource
// Delete Method
$scope.deleteTemplate = function(id){
$scope.templates.$delete({id: id});
}
}
在我绑定到templates
模型表多数民众赞成的观点。如下:
<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
方法和成功的DELETE
调用的REST API制作。但该视图在更新之前不会更新,并且$scope.templates = TemplateService.get();
会再次启动。我究竟做错了什么?
以及我们如何知道对REST API的异步调用是否成功?我很安静,确保angular的资源应该自行更新视图。如果我们手动更新客户端数据,我们还需要手动执行错误处理,这对我来说似乎是相反的。 – Amyth 2013-03-15 11:14:42
请你分享一下小提琴吧 – 2013-03-15 11:35:22