我正在使用Firebase和AngularFire来尝试保持我的数据同步。我的代码是:
var questionsRef, ref, ref1;
questionsRef = fbase.child("questions").orderByChild("subject").equalTo("english");
$scope.questions = $firebaseArray(questionsRef);
$scope.questions.$loaded().then(function() {
if ($stateParams.id) {
$scope.currentQuestion = $scope.questions.$getRecord($stateParams.id);
return console.log($scope.currentQuestion);
} else {
return $scope.currentQuestion = {
answers: []
};
}
});
$scope.currentQuestion.editedByUserId = (ref = auth.$getAuth()) != null ? (ref1 = ref.auth) != null ? ref1.uid : void 0 : void 0;
$scope.currentQuestion.editedOn = Firebase.ServerValue.TIMESTAMP;
$scope.currentQuestion.$save();
应该将更新保存到currentQuestion
(基于HTML中的表单ng-model
),而是Error: $scope.currentQuestion.$save is not a function. (In '$scope.currentQuestion.$save()', '$scope.currentQuestion.$save' is undefined)
我做错了什么?
答案 0 :(得分:0)
$scope.questions.$save($scope.currentQuestion)
由于$save
列在questions
数组