m-e-conroy / angular-dialog-service

A complete AngularJS service with controllers and templates for generating application modals and dialogs for use with Angular-UI-Bootstrap and Twitter Bootstrap

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stop propagation

BartoGabriel opened this issue · comments

Maybe someone will serve my resolution to the next problem.

I have a dropdown in which the user can select options, and has a button to apply the changes.
In the event that the user does not select anything, I show an error that asks the user to select something.
My problem is that when the user clicks close, the dropdown is also closed.

The solution is to put a stopPropagation to close function:

https://github.com/m-e-conroy/angular-dialog-service/blob/master/src/dialogs.js#L96

$scope.close = function ($event) {
  $modalInstance.close();
  $scope.$destroy();
  $event.stopPropagation();
};

Note that you must change the templates.

ng-click="close($event)"

I think it should be by default. Since you can do whatever you want after closing the dialogue. Needless to propagate the click event.