JanStevens / angular-growl-2

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

Ability to close message manually? #93

Closed sistemanick closed 9 years ago

sistemanick commented 9 years ago

Is it possible to close messages manually? For e.g.

msg = growl.info('Hello...');
msg.destroy();
flippinjoe commented 9 years ago

Hmm. Currently this is doable by

msg = growl.info('Hello...');

growlMessages.deleteMessage(msg);

However, it might be nice to have a more direct approach that you've got above.

sistemanick commented 9 years ago

@flippinjoe21 Thanks. I tried your suggestion but getting "cannot read property 'messages'" error.

I've set up a plunk here: http://plnkr.co/edit/1HqDTKl6cj5Yrqp7TDT5?p=preview

callicles commented 9 years ago

Another cool thing would be to enable cleaning up all current growls with something like growl.dismissAll()

The use case: I change state from the login state to the home state. I failed to enter the right password once before the change state so I have a growl saying that my password of login in incorrect. Once I enter correctly my password and get to the home state, I want to clean all error growls that might be displayed.

flippinjoe commented 9 years ago

So after taking a more in depth look. I've found that both of these are already in there.

For a single message you can destroy manually by

var msg = growl.info('blah');
msg.destroy();

For multi-messages you can do

growlMessages.destroyAllMessages();

There was a potential issue around this not working if you did not have <div growl> linked into your linked into your html yet. But I believe that is now resolved in the latest v0.7.5.

Closing for now

sistemanick commented 9 years ago

Thanks 0.7.5 fixed it.