JanStevens / angular-growl-2

growl-like notifications for angularJS projects
MIT License
285 stars 97 forks source link

growl not working in angular.module.run #19

Closed dapids closed 10 years ago

dapids commented 10 years ago

Hello everyone,

I don't know whether this is a bug or not, but currently the growl's functions do not work when they are invoked within angular.module.run.

Example:

angular
    .module('justAModule', [
        'angular-growl'
    ])
    .run(function(growl) {
        growl.info('Just an info');
    });

In particular the functions seem to fail silently. Any thoughts?

nlwillia commented 10 years ago

The growl directive isn't attached to the DOM yet and can't receive the "growlMessage" event. If you can wait until your UI has rendered to broadcast, then the message should render. For angular-growl to handle this, the service would have to track whether the directive was attached yet and buffer messages until it was. It's much simpler to just wait for the UI since no messages can display until the directive is present anyway.

dapids commented 10 years ago

Hi nlwillia,

Thanks for your reply. I eventually followed your tip and waited for the UI to be rendered before broadcasting the message.

Of course it works like a charm. ;)

Have a wonderful day. David