再次返回新类型错误。立即开始进行身份验证。使用AngularJS和firebase。现在当我点击提交按钮运行我的功能时,我在我的控制台中得到了这个“TypeError:this.mRef.auth不是一个函数”。我认为这很简单,但这是我的登录控制器:
.controller('Login', ['$scope', 'angularFire',
function($scope, angularFire) {
$scope.signin = function(){
var ref = "https://myappurl.firebaseio.com";
var auth = new FirebaseAuthClient(ref, function(error, user) {
if (user) {
// user authenticated with Firebase
console.log(user);
} else if (error) {
// an error occurred authenticating the user
console.log(error);
} else {
// user is logged out
console.log("hello");
}
});
console.log($scope);
var user = $scope.cred.user;
var pass = $scope.cred.password;
auth.login('password', {
email: user,
password: pass,
rememberMe: false
});
}
}])
接下来是html。我把它放在一个名为login的控制器中,这里有它的内容:
<div class="inner loginbox" ng-controler="Login"
<fieldset>
<label class ="white">Username</label>
<input type="text" id="username" ng-model="cred.user">
<span class="help-block"></span>
<label class ="white">Password</label>
<input type="password" id="password" ng-model="cred.password">
<div class="centerit rem-me">
<label class="checkbox">
<div class="white">Remember me?
<input type="checkbox" ng-model="cred.remember">
</div>
</label>
</div>
<div class="spacer1">
</div>
<a class="btn btn-inverse btn-large btn-width" id="signupsubmit" ng-click="signin()">Sign in</a>
</fieldset>
</div>
我得到的类型错误是指第79行的firebase-auth-client.js。在chrome中我在控制台中有这个:Uncaught TypeError:Object https://kingpinapp.firebaseio.com没有方法'auth'
答案 0 :(得分:2)
在实例化FirebaseAuthClient时,您应该传递实际的Firebase引用,而不仅仅是字符串表示形式。
更新代码以使用以下代码段可以解决您的问题:
var ref = new Firebase("https://myappurl.firebaseio.com");
var auth = new FirebaseAuthClient(ref, function(error, user) {