0

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?

monstro
  • 6,254
  • 10
  • 65
  • 111
  • Easy to manage in what way, to me, its the opposite, you need to inject it first in order to use, what for? – monstro Apr 11 '17 at 04:18
  • AngularJS comes with [dependency injection](https://docs.angularjs.org/guide/di) built-in, which makes testing components much easier, because you can pass in a component's dependencies and stub or mock them as you wish. Components that have their dependencies injected allow them to be easily mocked on a test by test basis, without having to mess with any global variables that could inadvertently affect another test. See [AngularJS Developer Guide - Why Dependency Injection?](https://docs.angularjs.org/guide/di#why-dependency-injection-) – georgeawg Apr 11 '17 at 11:17

1 Answers1

1

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.

Explosion Pills
  • 188,624
  • 52
  • 326
  • 405
  • All its doing is showing a message, not sure if I understand what's angular about it, its like taking js alert() and call it angular-alert so that it will be more difficult to use it – monstro Apr 11 '17 at 04:16