[英]auth issues with angular and firebase, undefined is not a function, how to?
i am trying to use the firebase user authentication and management to register, login, etc a user 我正在尝试使用Firebase用户身份验证和管理来注册,登录等用户
but i have issues getting $getAuth()
or $createUser()
, they come in as undefined is not a function
, also $getCurrentUser()
seems to be missing 但是我在获取
$getAuth()
或$createUser()
时遇到问题,因为undefined is not a function
,所以它们进来undefined is not a function
,也似乎缺少$getCurrentUser()
example: 例:
angular.module('starter.services', [])
.factory('Auth', function ($q, $firebase, FBURL, $location, $rootScope, localStorageService) {
var ref = new Firebase(FBURL);
var auth = $firebase(ref);
console.log(auth.$getAuth()); //undefined is not a function
any ideas? 有任何想法吗?
i am using AngularFire 0.9.0
, Firebase v2.0.4
, AngularJS v1.3.3
. 我正在使用
AngularFire 0.9.0
, Firebase v2.0.4
, AngularJS v1.3.3
。
You seem to have some copy/paste/modify errors from the examples. 您似乎从示例中复制/粘贴/修改了一些错误。
$getAuth
is an AngularFire method, so it is not defined on a regulare Firebase JavaScript ref. $getAuth
是AngularFire方法,因此在常规Firebase JavaScript参考上未定义。
The simplest example I could quickly code up: 我可以快速编写最简单的示例:
angular.module('app', ['firebase'])
.constant('FBURL', "https://your.firebaseio.com")
.factory("Auth", function($firebaseAuth, FBURL) {
var ref = new Firebase(FBURL);
return $firebaseAuth(ref);
})
.controller('MainCtrl', function ($scope, Auth) {
$scope.auth = Auth;
console.log(Auth.$getAuth());
})
;
Note that this will only log something meaningful if the user is logged in, otherwise it will log null
. 请注意,这只会在用户登录时记录有意义的内容,否则将记录
null
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.