在我的角度應用程序後,認爲我有一個控制器如下:
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