我一直在使用AngularFire .5和Firebase (这两个都是从Bower Install获得的)。
我从筛选Firereader代码库开始,并一直致力于更新这些方法。到目前为止一切都很好,而且我认为一切似乎都很好。
我能够初始化传入我的$firebaseAuth url的firebaseio.com。页面加载很好。
我使用的要求,模块化的一切,并引导角手动。
我似乎在挣扎的地方,是知道要加载哪些指令,以及什么时候,基于大量的样本和文档都处于不同的完成状态(我完全理解)。
我的应用程序初始化如下-
define([
'angular',
'angular-route',
'ui-bootstrap',
'ui-bootstrap-tpls',
'./controllers/index',
'./directives/index',
'./filters/index',
'./services/index',
'Firebase',
'angularFire',
'Firebase-Auth-Client',
'Firebase-Simple-Login',
'underscore'
], function (angular) {
'use strict';
return angular.module('app', [
'app.controllers',
'app.directives',
'app.filters',
'app.services',
'ngRoute',
'ui.bootstrap',
'ui.bootstrap.tpls',
'firebase'
]);
});不确定我的需要是否需要调整-比如简单登录或auth客户端需要防火墙?这可能是其中的一部分。
另一个问题是,我还在学习安古拉杰,这可能只是我的一个骨子里的举动,我试图让它发挥作用。
我已经创建了一个服务来处理所有的身份验证(基于Firebase示例,但是尝试从零开始工作,以获得所有身份验证的诀窍)。
服务看起来是这样的-
services.factory('authManager', ['$rootScope', 'fbRef', '$firebaseAuth', function($rootScope, fbRef, $firebaseAuth) {
//authScopeUtil($rootScope);
$rootScope.auth = $firebaseAuth(fbRef(),{
'path' : '/'
});
$rootScope.auth = {
authenticated: false,
user: null,
name: null
};
// provide some convenience methods to log in and out
return {
login: function(providerId) {
//$firebaseAuth.login(providerId, {scope: 'email'});
console.log(providerId);
},
logout: function() {
$firebaseAuth.logout();
},
createUser: function(data) {
var email = data.email;
var password = data.password;
$firebaseAuth.createUser(email, password, function(error, user){
if (!error) {
console.log('User Id: ' + user.id + ', Email: ' + user.email);
}
})
}
};
}]);fbRef看起来像这样-
services.factory('fbRef', ['fbUrl', 'Firebase', function(fbUrl, Firebase) {
// url can be an array or string
return function(url, limit) {
var ref = new Firebase(fbUrl(url));
if( limit ){
ref = ref.limit(limit);
}
return ref;
}
}]);也许这应该是new FirebaseSimpleLogin
当我运行代码时,我得到以下错误-
TypeError: Object function (ref, options) {
var auth = new AngularFireAuth($q, $t, $i, $rs, $l, ref, options);
return auth.construct();
} has no method 'createUser'我不知道我是否需要$createUser、$firebaseAuth、AngularFireAuth等等。到目前为止,似乎没有什么能解决这个错误,请允许我调用createUser()函数大纲这里和这里。
抱歉,太长时间了(这里可能真的很天真)--只是不知道还有什么地方可以改变。
发布于 2013-12-31 21:37:43
$firebaseAuth的预期用法是创建一个实例,然后调用该对象上的方法:
var auth = $firebaseAuth(ref);
auth.$createUser(...);https://stackoverflow.com/questions/20861943
复制相似问题