angular-toastr vs toastr? "angular" 有什么好处?

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

这听起来像是一个愚蠢的问题,但有什么区别呢?他们看起来和我一模一样。

https://github.com/CodeSeven/toastr

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

使用 angular-toastr,您可以将其作为依赖项注入(angular 方式)。

就这些?但是,如果你可以直接使用 toastr 呢?

您可以直接使用 toastr,但通常像这样的库会使用 Angular 摘要周期执行更新和响应使用事件。如果不这样做,那么任何依赖 Angular 数据绑定或摘要循环的东西都将无法正常工作,即它可能无法正确更新您的视图。

您可以看到几个地方,例如 this mouseleave this $interval

如果不这样做,进度条将不会在 mouseleave 事件中直观地更新,因为它不会在 Angular 摘要周期中更新。