tve*_*his 5 angularjs firebase angularfire pug
以下是我视图中的相关代码:
p(ng-repeat="t in todos")
input(
type="checkbox",
ng-model="t.done",
ng-click="clearItem($event)"
)
{{t.text}} done? {{t.done}}
Run Code Online (Sandbox Code Playgroud)
单击该复选框时,我希望todos
从数据库中删除数组中的相应对象.
我的clearItem
功能如下:
$scope.clearItem = function(event) {
todoRef.remove($scope.t);
}
Run Code Online (Sandbox Code Playgroud)
但是,这会删除我的数据库中的所有条目.我希望它只删除有问题的特定对象.反正我还能这样做吗?
好吧,想通了.
循环使用时ng-repeat
,请使用(id, t) in todos
.这允许您id
作为参数发送到ng-click
函数,并且$scope.todos.$remove(id)
工作得很好.
归档时间: |
|
查看次数: |
5006 次 |
最近记录: |