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
MIT License
618 stars 228 forks source link

Stop propagation #139

Open BartoGabriel opened 8 years ago

BartoGabriel commented 8 years ago

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.