My deletion, you can delete a task individually, or you can delete it by category (category and task collection that belongs to this category).
First page
task.ng.html
Confirm><span class= "Glyphicon glyphicon-trash icon" ></span></span>
Taskcontroller
$scope. OK = function (Task) {
$scope. Tasks.remove (Task);
};
Type.ng.html
<span class= "Glyphicon glyphicon-trash typeedit" confirm style= "MARGIN-RIGHT:5PX;Z-INDEX:5;" >
Typecontroller
$scope. OK = function (type) {
/*removetasksservice is inject service */
Removetasksservice.removetasksbytype (type._id);
$scope. Types.remove (type);
};
Directive.js:
angular.module (' demoone '). Directive (' Confirm ', [' $modal ', function ($modal) {
return {
restrict: ' A ',
Scope:true,
link:function (scope, element, Attrs) {
element.bind ("click", Function () {
//confirmservice.open (attrs.confirm);
var modalconfirminstance = $modal. Open ({
templateurl: ' client/tasks/views/mydeleteconfirm.ng.html ',
controller:[' $scope ', ' $modalInstance ', function ($scope, $modalConfirmInstance) {
//get obj from parent Controller
if (scope. task!=null) {
$scope. obj = Scope.task;
}else{
$scope. obj = Scope.type;
}
$scope is this controller scope object, and scope inherits the parent scope object thereby creating a new action object that can access methods and properties in the parent class
$scope. determine = function (obj) {
scope. OK (obj); Run the parent controller method
$modalConfirmInstance. Close (true);
};
$scope. Cancel = function () {
$modalConfirmInstance. Dismiss (' Cancel ');
};
}],
size: ' MD '
});
});
}
}
}])
Deleting a confirmation box with a custom directive implementation in angular