简单的待办事项列表,但列表页面上的每个项目都有一个删除按钮:
相关模板HTML:
<tr ng-repeat="person in persons">
<td>{{person.name}} - # {{person.id}}</td>
<td>{{person.description}}</td>
<td nowrap=nowrap>
<a href="#!/edit"><i class="icon-edit"></i></a>
<button ng-click="delete(person)"><i class="icon-minus-sign"></i></button>
</td>
</tr>
相关控制器方法:
$scope.delete = function (person) {
API.DeletePerson({ id: person.id }, function (success) {
// I need some code here to pull the person from my scope.
});
};
我试了$scope.persons.pull(person)
和$scope.persons.remove(person)
.
虽然数据库已成功删除,但我不能将此项目从作用域中拉出,并且我不想对服务器进行方法调用,以获取客户端已有的数据,我只想将此人从作用域中删除.
有什么 idea 吗?