【发布时间】:2016-09-08 04:10:01
【问题描述】:
我尝试将新记录推送到我的 Firebase。但每次我收到这样的控制台错误:
$scope.contacts.$add is not a function
这是我的代码:
app.controller('contactsCtrl',['$scope','$firebaseObject',function($scope,$firebaseObject){
var ref = new Firebase("https://<database_details>.firebaseio.com/contacts");
$scope.contacts = $firebaseObject(ref)
$scope.addContact = function(){
$scope.contacts.$add({
name: $scope.name,
address: $scope.address,
telephone: $scope.telephone,
company: $scope.company,
email: $scope.email
}).then(function(ref){
var id = ref.key();
console.log('contact added with Id: ' + id);
});
};
}]);
【问题讨论】:
标签: angularjs firebase firebase-realtime-database angularfire