Here's a plunkr demonstrating my problem(you have to open up console). How to try it?
click Notification button. Then in the console, there is:
Notification broadcasted. example.js:44
2 Notification received.
Which means the notification is received twice. That is because the controller for the modal is called on each open(). My problem is, that I just want it to be called once for the modal. I know that $on() return unregister function, but in my app I have quite a few events registered and I don't want to be unregistering them each time modal is closed. I also cannot have $on() anywhere else, because I need to work with dialog itself. Isn't there some easier way of ensuring, that for each modal dialog, I have the $scope events registered only once?
The plnkr doesn't work (currently), and a smaller plnkr showing just the issue would be better.
In your open() and close() functions in ModalDemoCtrl, how about toggling a $scope property (e.g., $scope.showModal) that tracks the state of your modal. When it is already open, don't call modelService() again.