AngularFire 0.9解决与UI路由器 [英] AngularFire 0.9 resolve with UI router
问题描述
我跟着教程这里但不知何故得到这个错误
未知提供商:currentAuthProvider< - currentAuth
我添加currentAuth我所有的控制器,可能是什么问题?
火力地堡2.0.4
AngularFire 0.9.0
下面是路由文件:
的.config(函数($ stateProvider,$ urlRouterProvider,$ locationProvider){ $ urlRouterProvider.otherwise('/'); $ stateProvider .STATE('家',{
网址:'/',
templateUrl:意见/ home.html做为',
控制器:homeCtrl
解析:{
currentAuth:userFactory功能(userFactory){
返回userFactory $ waitForAuth()。
}]
}
})
我只有两个模块:
VAR经= angular.module('经',[
'火力',
ui.router
])
和这是控制器之一:
angular.module('经')
.controller(signupCtrl,[$ rootScope,$范围,userFactory','$窗口','$火力点,$位置','用户','currentAuth',
功能($ rootScope,$范围,userFactory,$窗口,$火力点,$位置,用户currentAuth){
检查您的HTML局部视图,并删除在 NG-控制器声明。
NgRoute实例化控制器,你和它绑定到您的视图定义的DOM,所以没有必要在视图的部分HTML指定与 NG-控制器控制器。
本作品:
<! - 在它自己的HTML文件,说意见/ signupCtrl.html - >
< DIV> <! - 你看,不需要NG控制器=signupCtrl... - >
...注册表单等等...
< / DIV>
发生什么,如果你的做在那里留下NG控制器定义(我怀疑是你做了什么)是角将尝试两次实例化控制器:
- 一旦当它加载DOM时,此时遇到它的 currentAuth 将不会被定义,所以你会得到一个未知提供商错误,如果它的上市为在您的控制器的依赖。
- 仙界的决心完成。
I've followed a tutorial here but somehow getting this mistake
Unknown provider: currentAuthProvider <- currentAuth
i added currentAuth to all my controllers, what might be wrong?
Firebase 2.0.4
AngularFire 0.9.0
Here's the routes file:
.config(function($stateProvider, $urlRouterProvider, $locationProvider) {
$urlRouterProvider.otherwise('/');
$stateProvider
.state('home', {
url: '/',
templateUrl: 'views/home.html',
controller: "homeCtrl",
resolve: {
"currentAuth": ["userFactory", function(userFactory) {
return userFactory.$waitForAuth();
}]
}
})
i have only two modules:
var warp = angular.module('warp', [
'firebase',
'ui.router'
])
and this is one of controllers:
angular.module('warp')
.controller("signupCtrl", ["$rootScope", '$scope', 'userFactory', '$window', '$firebase', '$location', 'USERS', 'currentAuth',
function($rootScope, $scope, userFactory, $window, $firebase, $location, USERS, currentAuth) {
Check your HTML partial view and remove the ng-controller declaration.
NgRoute instantiates the controller for you and binds it to the DOM defined in your view, so there is no need to specify the controller with ng-controller in the view's partial HTML.
This works:
<!-- in it's own HTML file, say views/signupCtrl.html -->
<div> <!-- Look, no need for ng-controller="signupCtrl"... -->
...signup Form etc...
</div>
What happens if you do leave a ng-controller definition in there (which I suspect is what you did) is that angular will try to instantiates the controller twice:
- Once when it encounters it when loading the DOM, at which point currentAuth won't be defined, so you would get an unknow provider error if it's listed as a dependency in your controller.
- Once upon resolve completing.
这篇关于AngularFire 0.9解决与UI路由器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!