我有一个调用addCheckin()
方法的页面,它位于控制器内部。在控制器中,我尝试按如下方式创建引用:
var ref = firebase.database().ref("users/" + $scope.whichuser + "/meetings/" +$scope.whichmeeting + "/checkins");
$scope.whichuser
和$scope.whichmeeting
是我从另一条路线传递的$routeParams
。
这是我的签到控制器 -
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*/
我在这里遇到两个错误 -
错误1:
错误:/ users / Vp2P1MqKm7ckXqV2Uy3OzTnn6bB3 / meetings上的permission_denied:客户端无权访问所需数据。
错误2:
错误:在/ users / Vp2P1MqKm7ckXqV2Uy3OzTnn6bB3 / meetings / -KT5tqMYKXsFssmcRLm6 / checkins上的permission_denied:客户端无权访问所需数据。
这就是我想要实现的目标:
这是我的数据库JSON树:
{
"users" : {
"43ZU72ndoKb9LSEjBODKXe3nrou1" : {
"email" : "roy@123.com",
"firstname" : "Roy",
"lastname" : "Marshal",
"regUser" : "43ZU72ndoKb9LSEjBODKXe3nrou1"
},
"BHcYb40FC8YlCKL54ngyMhxPx2q1" : {
"date" : 1475574109981,
"email" : "sky@on.com",
"firstname" : "Sky",
"lastname" : "Thakur",
"meetings" : {
"-KTE3_45wXBqd-_yR1xv" : {
"date" : 1475574125198,
"name" : "ARET"
}
},
"regUser" : "BHcYb40FC8YlCKL54ngyMhxPx2q1"
},
"Vp2P1MqKm7ckXqV2Uy3OzTnn6bB3" : {
"email" : "jon@me.com",
"firstname" : "John",
"lastname" : "Cena",
"meetings" : {
"-KT5tqMYKXsFssmcRLm6" : {
"date" : 1475437094667,
"name" : "hourly"
},
"-KTAvH-ZkWyxrJrK_SDb" : {
"date" : 1475521356544,
"name" : "Hourly"
},
"-KTAwV69txdeT4i_horE" : {
"date" : 1475521676006,
"name" : "asdfg"
},
"-KTAwkH35EyPQZ17DmN9" : {
"date" : 1475521742244,
"name" : "qwerty"
},
"-KTAwsrqe24e8wFfRxpN" : {
"date" : 1475521777422,
"name" : "asfdsf"
},
"-KTAyYPSZLQUtOJ4g8Ak" : {
"date" : 1475522213781,
"name" : "Yearly"
},
"-KTB05PfXZLLk9Of3_Nb" : {
"date" : 1475522881473,
"name" : "Meet"
},
"-KTBG2cP9YLoP4lalN5M" : {
"date" : 1475527064378,
"name" : "JOI"
}
},
"regUser" : "Vp2P1MqKm7ckXqV2Uy3OzTnn6bB3"
}
}
}
我的数据库规则是:
{
"rules": {
".read": true,
".write": true
}
}
我之前也发过这个问题,但没有得到任何合适的解决方案。