【发布时间】:2016-05-13 23:24:17
【问题描述】:
我已经创建了我的登录名,并且现在能够允许用户注册。但是我想将用户数据存储到我的节点。我添加了我认为应该在 addUser 函数中工作的代码。我已经为此工作了很长时间,但找不到解决方案。有人可以指出我做错了什么的正确方向吗?
我写的代码如下。提前致谢。
'use strict';
var theBigWeddingBook = angular.module('theBigWeddingBook');
theBigWeddingBook.controller('RegCtrl', function ($scope, $firebaseAuth, $firebaseObject)
{
var ref = new Firebase("https://the-big-wedding-book.firebaseio.com");
var reg = $firebaseAuth(ref);
$scope.user = {};
$scope.addUser = function() {
var username = $scope.user.email;
var password = $scope.user.password;
var uid = $scope.user.uid;
reg.$createUser({
email: username,
password: password
}).then(function(user) {
console.log('User has been successfully created!');
}).catch(function(error) {
console.log(error);
})
ref.child('user').child(user.uid).set(user).then(function(user) {
console.log('Data Saved Successfully!');
}).catch(function(error) {
console.log(error);
})
};
})
【问题讨论】:
标签: angularjs firebase angularfire firebase-realtime-database firebase-authentication