0
我在这里遇到了问题。 下面的代码是检查用户状态,然后返回应用程序的名字和其他信息。目前我无法访问从Firebase数据库返回的firstname和其他对象。有没有其他方法可以使用,还是我在这里做非法的事情?我一直在努力挣扎。欢迎任何帮助或建议。Firebase角度数据
myApp.controller('StatusController',
function ($scope, $rootScope, $firebaseAuth, FIREBASE_URL, $location, Authentication) {
$scope.logout = function(){
Authentication.logout();
$location.path('/login');
}
var authData = new Firebase(FIREBASE_URL + '/users/');
var syncAuthData = $firebaseAuth(authData).$asObject();
if (syncAuthData) {
$scope.currentUser = syncAuthData; // Here currentUser should access firstname and etc
console.log("Logged in as:", syncAuthData);
} else {
console.log("Logged out");
$scope.currentUser = null;
}
////var authData = syncAuthData.$getAuth();
//if (syncAuthData) {
// $scope.currentUser = syncAuthData;
// console.log("Logged in as:", syncAuthData);
//} else {
// console.log("Logged out");
// $scope.currentUser = null;
//}
});//Statuscontroller
使用$ getAuth()的[文档建议](https://www.firebase.com/docs/web/libraries/angular/guide.html#section-angular-authentication)。 – Kato 2014-12-04 21:45:51
谢谢。这很有帮助。它运作良好。 – 2014-12-06 02:25:14