-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Used in a service, toastr.clear() not working #137
Comments
It shouldn't give you any problem at all. In Angular, services (like toastr) is a singleton, so no matter where you call it, it will always have the same data. |
Have you found a solution for this issue? I am running in exactly the same problem. |
I would love some reproduction. |
Add an empty array and it wont work. Leave out the array and it works. myCtrl.function = function(){ } FileManager.uploadFile = function(fileToUpload, mytoast){ |
|
@Foxandxss your example here makes it look a lot like the toast is supposed to be in an array. I'm also having trouble with this and cannot get it to work, are there specific |
And you are totally right. That syntax is used when you have an optional parameter, say You shouldn't need to do something special to clear toasts. What are you trying? |
@Foxandxss, thanks for fast response! function show(msg, opts = {}) {
var notification = toastr.info(msg, opts);
notification.removeSelf = () => toastr.clear(notification);
return notification;
} And when I do |
|
In reaction to this comment, I believe that it should be made clearer in the documentation that this is not an array notation, but rather an optional parameter notation. I fell into that trap too although once the "optional parameter" explanation comes in, it feels like a "dumb me, I know that!!!" moment. |
I encountered this also. Seems |
Hi,
As in the title, calling the clear method doesn't work when toastr is used in service/factory. Calling them to show works, no problem.
How exactly can this be used in a service?
Thanks
The text was updated successfully, but these errors were encountered: