저는 ionic (v1)과 angularfire로 간단한 CRUD를하려고합니다. 레코드를 읽고 삭제할 수는 있지만 편집하고 작성해야합니다. 실제 문제는 anglefire function $ 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
를 돌려 약간의 오차가 있었다하지 않습니다 :이 코드가 있습니다. 어떤 아이디어? 자바 스크립트 then
다시 성공을위한 하나 지금
$scope.user.$add(data).then(function (success){
return console.log(success);
}, function(error){
return console.log(error);
})
아래의 코드와 같은 실패 뭔가 다른 전화를하는 데 걸리는 오류가있는 경우
오류는 "오류 : 키 ID가 정의되지 않았습니다 .JSON에서 정의되지 않은 항목을 전달할 수 없습니다. 대신 null을 사용하십시오." –