我有一个使用 Firebase 作为后端的 Angular 应用程序,我正在尝试将“ toastr ”作为我的授权应用程序工厂中的依赖项注入(inject)。这是 app.factory 的开始
app.factory('principal', ['$rootScope',
'$q', '$http', '$timeout', '$firebaseAuth', "$firebaseObject", '$filter','$firebaseArray', '$state', 'toaster'
function ($rootScope, $q, $http, $timeout, $firebaseAuth, $firebaseObject, $filter, $firebaseArray, $state, toaster)
使用此配置,应用程序将不会加载。我可以在我的 Controller 内使用“ toastr ”,但在工厂内它会破坏我的应用程序。我是 Angular 的新手,所以我不知道我是否遗漏了某些东西或完全偏离了向工厂添加此类依赖项的基础。
我需要一个简单的 toastr 弹出来提醒密码不正确。我应该只创建一个单独的 Controller 来处理这个吗?
最佳答案
您错过了在 View 中添加 toaster
容器,以便消息显示在该容器内。
标记
<toaster-container
toaster-options="{'time-out': 3000, 'animation-class': 'toast-top-center'}">
</toaster-container>
关于javascript - Angular App Factory toastr 作为依赖打破应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30005221/