AngularFire,如何通过uid在页面上显示name/email?
AngularFire, how to show name/email on page through uid?
正如题目所说,如何在页面上打印出来?
许多与此相关的其他主题都在使用 SimpleLogin,现在已弃用,因此使用不多,因此另一个线程..
我有一个注册功能(名称+电子邮件+密码)和一个登录功能(电子邮件+密码),当通过身份验证时我希望页面打印 "Welcome {{user.name}}" 例如。
我觉得这是一项非常基本的任务,但我无法完成。当授权并重定向到 dashboard.html(那里的路由存在一些问题,但那是另一个 post,提示提示)- 它只打印出 uid。
看起来像这样:
app.controller('dashController', ['currentAuth', '$scope', '$firebaseArray', '$firebaseAuth', '$rootScope', 'Auth', '$location',
function(currentAuth, $scope, $firebaseArray, $firebaseAuth, $rootScope, Auth, $location){
var ref = new Firebase('https://url.firebaseio.com');
$scope.auth = $firebaseAuth(ref);
$scope.user = $firebaseArray(ref);
var authData = $scope.auth.$getAuth();
$scope.id = authData.uid;
}]);
和html:
<span>Welcome {{id}}</span>
所有 uid 都存储在 /users/uid/name+email+pass 中。
谢谢!
这没有任何意义:
$scope.user = $firebaseArray(ref);
您的数据库不是数组,因此尝试将其作为数组绑定到作用域对任何人都没有帮助。
您更有可能希望将特定用户的配置文件数据绑定到范围:
$scope.user = $firebaseObject(ref.child('users').child(authData.uid));
然后在您看来:
<span>Welcome {{user.name}}</span>
我建议您从头到尾遵循 AngularFire programming guide。例如,这样做应该使 $firebaseArray()
和 $firebaseObject()
之间的区别更清楚。
正如题目所说,如何在页面上打印出来? 许多与此相关的其他主题都在使用 SimpleLogin,现在已弃用,因此使用不多,因此另一个线程..
我有一个注册功能(名称+电子邮件+密码)和一个登录功能(电子邮件+密码),当通过身份验证时我希望页面打印 "Welcome {{user.name}}" 例如。 我觉得这是一项非常基本的任务,但我无法完成。当授权并重定向到 dashboard.html(那里的路由存在一些问题,但那是另一个 post,提示提示)- 它只打印出 uid。
看起来像这样:
app.controller('dashController', ['currentAuth', '$scope', '$firebaseArray', '$firebaseAuth', '$rootScope', 'Auth', '$location',
function(currentAuth, $scope, $firebaseArray, $firebaseAuth, $rootScope, Auth, $location){
var ref = new Firebase('https://url.firebaseio.com');
$scope.auth = $firebaseAuth(ref);
$scope.user = $firebaseArray(ref);
var authData = $scope.auth.$getAuth();
$scope.id = authData.uid;
}]);
和html:
<span>Welcome {{id}}</span>
所有 uid 都存储在 /users/uid/name+email+pass 中。 谢谢!
这没有任何意义:
$scope.user = $firebaseArray(ref);
您的数据库不是数组,因此尝试将其作为数组绑定到作用域对任何人都没有帮助。
您更有可能希望将特定用户的配置文件数据绑定到范围:
$scope.user = $firebaseObject(ref.child('users').child(authData.uid));
然后在您看来:
<span>Welcome {{user.name}}</span>
我建议您从头到尾遵循 AngularFire programming guide。例如,这样做应该使 $firebaseArray()
和 $firebaseObject()
之间的区别更清楚。