I have a tasklist that contains some task, When I add a task from it, it removes from the list. How Can I avoid that so that I will be available for adding multiple time. Here is the view code :-
<a ng-if="editable" ng-click="makeManualTasksList();" class="marL10 marB15 showRowInfo freelancerInvoice">Add Custom Tasks </a>
And here is the controller code :-
$scope.makeManualTasksList = function() {
$scope.switchToTasksSelection = false;
$scope.selectBoxMannual = true;
$scope.availableTasksForSelection = [];
console.log("$scope.availableTasksForSelection", $scope.availableTasksForSelection);
var selectFlag = {
id: -1,
task: {
taskName: "Task"
},
order: "Task No.",
service: {
workOrder: {
jobNo: "Job No.",
jobName: "Job Name",
number: "WO No."
}
}
};
$scope.availableTasksForSelection.push(selectFlag);
angular.forEach($scope.capableTaskList, function(task, id) {
task.quantity = 1;
if (!task.isSelected) $scope.availableTasksForSelection.push(task);
});
$scope.selectedTask = $scope.availableTasksForSelection[0];
console.log("$scope.selectedTaskpawan", $scope.selectedTask);
};
答案 0 :(得分:0)
有一个变量 isSelected 导致列表出现问题。 现在。 在控制器中:
$scope.availableTasksForSelection.push(selectFlag);
angular.forEach($scope.capableTaskList, function(task, id) {
task.quantity = 1;
if (!task.selected) $scope.availableTasksForSelection.push(task);
});
$scope.selectedTask = $scope.availableTasksForSelection[0];
console.log("$scope.selectedTaskpawan", $scope.selectedTask);
PS:感谢所有看过我排队的人。