简单的待办事项列表,但每个项目的列表页面上都有一个删除按钮:
相关模板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>
Run Code Online (Sandbox Code Playgroud)
相关控制器方法:
$scope.delete = function (person) {
API.DeletePerson({ id: person.id }, function (success) {
// I need some code here to pull the person from my scope.
});
};
Run Code Online (Sandbox Code Playgroud)
我试着$scope.persons.pull(person)
和$scope.persons.remove(person)
.
虽然数据库已成功删除,但我无法从作用域中提取此项目,并且我不想对客户端已有的数据进行服务器方法调用,我只是想从范围中删除这一个人.
有任何想法吗?