Query: I am facing an issue with my checkbox system where a dialog pops up when trying to unflag a form by unchecking the box. The dialog asks for confirmation before removing the form. How can I ensure that the checkbox remains checked until the user clicks "Confirm" or "Cancel"? And how do I keep it checked if the user selects Cancel, and unchecked if they choose Confirm?
Below is the relevant code snippet:
file.js (contains angular module, controllers, etc.):
... //INSIDE controller 'ctrlOne'
$scope.fromService = dialog.deletionConfirmDialog('Title','Wanna remove?');
...
//OUTSIDE controller 'ctrlOne'
...
...
hello.service('dialog', function($mdDialog) {
this.deletionConfirmDialog = function(title, cont){
$mdDialog.show($mdDialog.confirm({
templateUrl: 'deletionConfirmDialog.html',
title : title,
textContent : cont,
ok : 'Confirm',
cancel: 'Cancel'
})).then(function() {
console.log('confirmed');
//to be completed
}, function() {
console.log('abort');
//to be completed
});
}
}
...
stepOne.html:
...
<div ng-repeat="item in serv" ng-model="item.active">
<md-checkbox id="{{item.id}}" aria-label="check" type="checkbox"> ng-model="item.attivo">
</div>
...
The stepOne.html page is linked to a specific controller ('ctrlOne').