Javascript 让孩子陷入角火
我真的不明白我做错了什么。所以,我所做的是,我试图获得图片中描述的特定用户的post值 因此,为了获得用户帖子,我使用了以下方法:Javascript 让孩子陷入角火,javascript,angularjs,firebase,angularfire,Javascript,Angularjs,Firebase,Angularfire,我真的不明白我做错了什么。所以,我所做的是,我试图获得图片中描述的特定用户的post值 因此,为了获得用户帖子,我使用了以下方法: app.controller('chatController', ["$scope", 'AuthService', "Auth", "Ref", "$rootScope","$firebaseArray", function($scope, AuthService, Auth, Ref, $rootScope, $firebaseArray) {
app.controller('chatController', ["$scope", 'AuthService', "Auth", "Ref", "$rootScope","$firebaseArray",
function($scope, AuthService, Auth, Ref, $rootScope, $firebaseArray) {
console.log(AuthService.User.email)//Gives me correct Email
console.log(AuthService.User.password)//Gives me correct password
console.log(AuthService.User.uid)//Gives me correct uid
console.log(AuthService.User.username)//Gives me correct username
var some = $firebaseArray(Ref.child("Posts").child(AuthService.User.username)); //Why Giving me an error here when i put that child in?
console.log((some))
var postsFirebase = $firebaseArray(Ref)
$scope.messages = postsFirebase
$scope.submit = function() {
if (!($scope.textValue)) {
//Checking for empty string
} else {
alert($scope.textValue)
Ref.child("Posts").child(AuthService.User.username).push({
"Posts": $scope.textValue
})
}
}
}
])
当我把孩子放在AuthService.User.username的第9行时,它会给我一个错误,告诉我:
错误:Firebase.child失败:第一个参数是无效路径:“null”。路径必须是非空字符串,并且不能包含“.”、“$”、“[”或“]”
我这里的主要问题是从孩子那里获取数据。谢谢
请帮帮我。谢谢 如果将用户名硬编码为Ref.child(“Posts”).child(“GREE”)
,问题是否消失?