【发布时间】:2017-10-11 23:43:56
【问题描述】:
我正在尝试使用 ionic (v1) 和 angularfire 进行简单的 CRUD。我可以读取和删除记录,但我需要编辑和创建。实际的问题是 angularfire 函数 $add`,这个函数没有做任何事情,也不会在控制台中返回任何错误。我有这个代码:
$scope.users = $firebaseArray(root.ref('/users/'));
$scope.user = {};
//Create
$scope.title = "New user"
$scope.button = "Create";
$scope.icon = "ion-person-add";
$scope.submit = function () {
var data = {
name: $scope.user.name,
username: $scope.user.username,
email: $scope.user.email,
street: $scope.user.street,
suite: $scope.user.suite,
city: $scope.user.city,
lat: $scope.user.lat,
lng: $scope.user.lng,
phone: $scope.user.phone,
website: $scope.user.website,
}
console.log(data);
$scope.users.$add(data).then(function (ref) {
console.log('contact added with Id: ' + id);;
})
显然代码没问题,但没有返回console.log,所以可能有一些错误。有什么想法吗?
【问题讨论】:
标签: angularjs firebase ionic-framework firebase-realtime-database angularfire