问题描述
我有一个页面正在调用控制器内的 addCheckin()
方法.在控制器中,我试图创建一个引用如下:
I have a page that is calling addCheckin()
method which is inside a controller. In the controller, I am trying to create a reference as follows:
var ref = firebase.database().ref("users/" + $scope.whichuser + "/meetings/" +$scope.whichmeeting + "/checkins");
$scope.whichuser
和 $scope.whichmeeting
是我从另一条路线传递的 $routeParams
.这是我的签入控制器-
$scope.whichuser
and $scope.whichmeeting
are the $routeParams
that I am passing from another route.Here's my checkin controller-
myApp.controller("CheckinsController",
['$scope','$rootScope','$firebaseArray','$routeParams','$firebaseObject',
function($scope,$rootScope,$firebaseArray,$routeParams,$firebaseObject){
$scope.whichuser = $routeParams.uid;
$scope.whichmeeting = $routeParams.mid;
var ref = firebase.database().ref("users/" + $scope.whichuser + "/meetings/" +$scope.whichmeeting + "/checkins");
$scope.addCheckin = function(){
var checkinInfo = $firebaseArray(ref);
var data={
firstname:$scope.firstname,
lastname:$scope.lastname,
email:$scope.email,
date:firebase.database.ServerValue.TIMESTAMP
}
checkinInfo.$add(data);
}
}]);/*controller*/
我在这里遇到了两个错误-
There are two errors that I am getting here-
错误 1:
错误:permission_denied at/users/Vp2P1MqKm7ckXqV2Uy3OzTnn6bB3/meetings:客户端无权访问所需数据.
错误 2:
错误:permission_denied at/users/Vp2P1MqKm7ckXqV2Uy3OzTnn6bB3/meetings/-KT5tqMYKXsFssmcRLm6/checkins:客户端无权访问所需数据.
这就是我要实现的目标-
And this is what I am tring to achieve-
推荐答案
转到应用的 Firebase 控制台
Go to Firebase console of your app
从侧面菜单中选择数据库 --> 从上面的选项卡中选择规则 --> 像这样更新你的规则
Select Database From Side Menu --> Select Rule From tabs above --> Update your rule like this
{
"rules": {
".read": true,
".write": true
}
}
希望它能解决您的问题.谢谢:)
hope it solve your problem . thanks :)
这篇关于客户端无权访问 Firebase 中的所需数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!