Ive been trying to figure out a way to have my function wait for my modal window to close before returning, but nothing I've tried has worked. I have a angularjs component that allows a user to add and remove tags. When the user removes a tag i want it to call my modal window and have them confirm if they want to delete the tag. However the function returns before the user can make their choice.
This is my tag html code. Im using npm tags-input. The attribute on-tag-removing expects a bool to be returned
<tags-input ng-model="formVm.form.tags" on-tag-removing="removingTagModal()" ></tags-input>
This is my angularjs code for opening the modal.
$scope.removingTagModal = function() {
var promiseDivRemove = new Promise(function(resolve, reject) {
$modal.open({
templateUrl: 'removeTagModal.html',
controller: 'RemoveTagModalController',
size: 'lg',
resolve: {
}
}).result.then(function(item) {
resolve(item);
});
});
return promiseDivRemove;
};
Here is the controller code for the modal
.controller('RemoveTagModalController', ['$scope', '$modalInstance', function($scope, $modalInstance) {
$scope.ok = function() {
$modalInstance.close(true);
};
$scope.cancel = function() {
$modalInstance.close(false);
};
}])
Via Active questions tagged javascript - Stack Overflow https://ift.tt/Eh9e0ZK
Comments
Post a Comment