I want to run the code if any modal opens. Usually I want something like:
$scope.$watch(function () { return $modal.isOpenState; }, function (val) {
But I did not know what to see. Yes, I can detect the open event for each instance, for example:
modalInstance.opened.then(function() {
But this is not DRY.
PS I can also do something like $('.modal').hasClass('in') in $watch , but it's a little ugly
PPS And btw I use ui-router to open modals (see faq here )
$modal.open({ templateUrl: "...", resolve: {... }, controller: function($scope) { ... } }).result.finally(function() {
javascript angularjs angularjs-scope angular-ui
Sergei Panfilov
source share