Open DWand opened 9 years ago
The preloading was a simple hack in case somebody tried to use the growl notifications and angular was still initialising the directive/controller. (recent bug of undefined messages).
I know it was a quick fix but I havent got the time to fix it properly, feel free to add a PR! thanks
@JanStevens, as for the PR - I'm not sure about a proper place for this fix and afraid to mess up the code.
@JanStevens, I've done some work with the code. You can see it here: https://github.com/DWand/angular-growl-2/tree/updates.
Hello. I use the AngularUI Router in my application. I've found that it is almost impossible to send notifications to growl directives in other views. Here is a use case:
There is an application with 2 pages/routes/states. The first page has the growl directive in a view:
<div growl inline="true" reference="page1"></div>
growl.success('Message', { referenceId: 'page1' });
As I understand, the problem is in this line of code: https://github.com/JanStevens/angular-growl-2/blob/master/src/growlDirective.js#L18
When the user navigates to the first page again, the directive tries to initialize itself once more time and clears all its messages here: https://github.com/JanStevens/angular-growl-2/blob/master/src/growlMessageService.js#L39
I have not dug deeply into the code and don't know why
directives
andpreloadDirectives
are separated. But this problem probably could be solved at least by preventing the directive from reinitialization (https://github.com/JanStevens/angular-growl-2/blob/master/src/growlDirective.js#L18):or by enhancing initialization logic (https://github.com/JanStevens/angular-growl-2/blob/master/src/growlMessageService.js#L32-L45):