我有一些独特的角度火力设置,其中任务的路径是任务的周和日。
//for example this references a day collection that has tasks as children
var ref = new Firebase("https://talllly.firebaseio.com/tasks/" + $scope.currentWeek + '/' + day.$id);
$scope.currentWeek and day.$id are timestamps.
我的问题是我似乎无法访问该子任务以便能够删除它。如何访问各个任务以便删除它们?
这是视图
<section class="col user-tasks" user-color color="{{profile.name}}">
<form ng-submit="addTask(task, user); task = null;">
<input placeholder="What are you working on today?" ng-model="task"/>
</form>
<ul class="tasks-list">
<li ng-repeat="day in week | reverseArray">
<span ng-show="day">{{getDisplayDate(day.$id) | date:'EEEE, MMMM d'}}</span>
<ul>
<li ng-repeat="(key, task) in day | orderBy:'doneTime' | reverse" ng-show="task.addedBy === profile.name">
<div class="row input-container">
<div class="small-1 columns">
<input type="checkbox" ng-model="task.complete" ng-change="change(task, day)">
</div>
<div class="small-10 columns">
<input type="text" ng-model="task.text" ng-change="update(task)">
</div>
<div class="small-1 columns">
<span ng-click="delete(day, task)">x</span>
</div>
</div>
</li>
</ul>
</li>
</ul>
</section>
另外,在相关的说明中但是如果有什么。$ id是对象的第一个值,我如何访问任务的-JXYiowyf-UerL3NeDm_级别?
编辑,更新以显示我正在获取任务的位置:
var populateTasks = function(date){
var tasks = "https://talllly.firebaseio.com/tasks/" + getWeekStart(date);
$scope.ref = new Firebase(tasks);
var sync = $firebase($scope.ref);
$scope.week = sync.$asArray();
};
更新: 我能够通过逐个重新创建功能来实现它。我仍然不完全确定发生了什么,但我的删除功能现在看起来像这样:
$scope.deleteTask = function(key, task, day){
var sync = new Firebase(FBURL + '/tasks/' + $scope.currentWeek + '/' + day.$id);
var deleteList = $firebase(sync);
deleteList.$remove(key)
.then();
};