私のAngularアプリには、次のようなコントローラーがあります。
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
が呼び出され、RESTAPIが正常に呼び出されます。$scope.templates = TemplateService.get();
ただし、ビューが更新されて再度開始されるまで、ビューは更新されません。私は何が間違っているのですか?