Search code examples
angularjsangular-toastr

angular-toastr vs toastr? whats the benefit of the "angular" one?


This may sound like a stupid question, but whats the difference? they look identical to me.

https://github.com/CodeSeven/toastr

https://github.com/Foxandxss/angular-toastr

With angular-toastr you can inject it as a dependency (the angular way).

That's it? But what for, if you can just use toastr directly?


Solution

  • You could possibly use toastr directly, but typically libraries like this perform updates and respond to use events using the Angular digest cycle. If this isn't done, then anything that relies on Angular data bindings or the digest cycle will not work properly, i.e. it might not properly update your views.

    You can see a couple of spots where this is done such as this mouseleave this $interval.

    If this wasn't done, the progressbar would not visually update on the mouseleave event because it wouldn't be updated during an Angular digest cycle.