AngularFire:如何更新非规范化数组/对象?

AngularFire:如何更新非规范化数组/对象?,angularfire,denormalized,Angularfire,Denormalized,我目前正在使用加藤的gist()用另一个Firebase路径规范化我的记录 我面临的问题是当我尝试将对象更新回firebase数据库时:数据库不更新(控制台中没有错误消息) 我的书桌如下所示: books: -JyDpkQrUozE3L7flpo: { title: "title1", author: {-JyDpkQrUozE3L7fl1x: true} }, -JyDpkQrUozE3L7flp1: { title: "title2",

我目前正在使用加藤的gist()用另一个Firebase路径规范化我的记录

我面临的问题是当我尝试将对象更新回firebase数据库时:数据库不更新(控制台中没有错误消息)

我的书桌如下所示:

books:
    -JyDpkQrUozE3L7flpo: {
    title: "title1",
    author: {-JyDpkQrUozE3L7fl1x: true}
    },
    -JyDpkQrUozE3L7flp1: {
    title: "title2",
    author: {-JyDptrrrezE3L7flKx: true}
    },
    -JyDpkQrUozE3L7flp2: {
    title: "title3",
    author: {-JyDpkQrUozE3L7f222: true}
    }
authors:
    -JyDpkQrUozE3L7flKx: {
        firstname: "jacques",
        lastname: "smith"
    },
    -JyDptrrrezE3L7flKx: {
        firstname: "bill",
        lastname: "halley"
    },
    -JyDpkQrUozE3L7f222: {
        firstname: "john",
        lastname: "ford"
    }
.factory('NormalizedBook’, ['$firebaseObject', 'firebaseService', function($firebaseObject, firebaseService) {
    var service = $firebaseObject.$extend({
        $$updated: function(snap) {
            var self = this;
            var record = $firebaseObject.prototype.$$updated.call(this, snap);
            firebaseService.$getAuthor( self.authorId ).$loaded().then(function( authorData ) {
                    self.authorFirstName = authorData.authorFirstName;
                    self.authorLastName = authorData.authorLastName;
            });
            return record;
        }
    });
    return service;
}])
.controller('booksController', ['$scope', '$firebaseArray', 'normalizedBook', function($scope, $firebaseArray, normalizedBook) {
    $scope.bookSelected = new normalizedBook(firebaseService.refBooks.child(id);    
    $scope.updateBookSelected = function(item) {
        $scope.bookSelected.$save(item);
    };
});
我的作者表如下所示:

books:
    -JyDpkQrUozE3L7flpo: {
    title: "title1",
    author: {-JyDpkQrUozE3L7fl1x: true}
    },
    -JyDpkQrUozE3L7flp1: {
    title: "title2",
    author: {-JyDptrrrezE3L7flKx: true}
    },
    -JyDpkQrUozE3L7flp2: {
    title: "title3",
    author: {-JyDpkQrUozE3L7f222: true}
    }
authors:
    -JyDpkQrUozE3L7flKx: {
        firstname: "jacques",
        lastname: "smith"
    },
    -JyDptrrrezE3L7flKx: {
        firstname: "bill",
        lastname: "halley"
    },
    -JyDpkQrUozE3L7f222: {
        firstname: "john",
        lastname: "ford"
    }
.factory('NormalizedBook’, ['$firebaseObject', 'firebaseService', function($firebaseObject, firebaseService) {
    var service = $firebaseObject.$extend({
        $$updated: function(snap) {
            var self = this;
            var record = $firebaseObject.prototype.$$updated.call(this, snap);
            firebaseService.$getAuthor( self.authorId ).$loaded().then(function( authorData ) {
                    self.authorFirstName = authorData.authorFirstName;
                    self.authorLastName = authorData.authorLastName;
            });
            return record;
        }
    });
    return service;
}])
.controller('booksController', ['$scope', '$firebaseArray', 'normalizedBook', function($scope, $firebaseArray, normalizedBook) {
    $scope.bookSelected = new normalizedBook(firebaseService.refBooks.child(id);    
    $scope.updateBookSelected = function(item) {
        $scope.bookSelected.$save(item);
    };
});
我为normalizedBook提供的服务如下所示:

books:
    -JyDpkQrUozE3L7flpo: {
    title: "title1",
    author: {-JyDpkQrUozE3L7fl1x: true}
    },
    -JyDpkQrUozE3L7flp1: {
    title: "title2",
    author: {-JyDptrrrezE3L7flKx: true}
    },
    -JyDpkQrUozE3L7flp2: {
    title: "title3",
    author: {-JyDpkQrUozE3L7f222: true}
    }
authors:
    -JyDpkQrUozE3L7flKx: {
        firstname: "jacques",
        lastname: "smith"
    },
    -JyDptrrrezE3L7flKx: {
        firstname: "bill",
        lastname: "halley"
    },
    -JyDpkQrUozE3L7f222: {
        firstname: "john",
        lastname: "ford"
    }
.factory('NormalizedBook’, ['$firebaseObject', 'firebaseService', function($firebaseObject, firebaseService) {
    var service = $firebaseObject.$extend({
        $$updated: function(snap) {
            var self = this;
            var record = $firebaseObject.prototype.$$updated.call(this, snap);
            firebaseService.$getAuthor( self.authorId ).$loaded().then(function( authorData ) {
                    self.authorFirstName = authorData.authorFirstName;
                    self.authorLastName = authorData.authorLastName;
            });
            return record;
        }
    });
    return service;
}])
.controller('booksController', ['$scope', '$firebaseArray', 'normalizedBook', function($scope, $firebaseArray, normalizedBook) {
    $scope.bookSelected = new normalizedBook(firebaseService.refBooks.child(id);    
    $scope.updateBookSelected = function(item) {
        $scope.bookSelected.$save(item);
    };
});
firebaseService只是一个用于检索我的数据的助手服务:

var service = {};
service.refAuthors = new Firebase(FBAuthors);
service.authors = $firebaseArray( refAuthors );
service.$getAuthor = function(id) {
    if( !service.authors.hasOwnProperty(id) ) {
        service.authors[id] = $firebaseObject(service.refAuthors.child(id));
    };
    return service.authors[id];
};
…….
return service;
我的控制器如下所示:

books:
    -JyDpkQrUozE3L7flpo: {
    title: "title1",
    author: {-JyDpkQrUozE3L7fl1x: true}
    },
    -JyDpkQrUozE3L7flp1: {
    title: "title2",
    author: {-JyDptrrrezE3L7flKx: true}
    },
    -JyDpkQrUozE3L7flp2: {
    title: "title3",
    author: {-JyDpkQrUozE3L7f222: true}
    }
authors:
    -JyDpkQrUozE3L7flKx: {
        firstname: "jacques",
        lastname: "smith"
    },
    -JyDptrrrezE3L7flKx: {
        firstname: "bill",
        lastname: "halley"
    },
    -JyDpkQrUozE3L7f222: {
        firstname: "john",
        lastname: "ford"
    }
.factory('NormalizedBook’, ['$firebaseObject', 'firebaseService', function($firebaseObject, firebaseService) {
    var service = $firebaseObject.$extend({
        $$updated: function(snap) {
            var self = this;
            var record = $firebaseObject.prototype.$$updated.call(this, snap);
            firebaseService.$getAuthor( self.authorId ).$loaded().then(function( authorData ) {
                    self.authorFirstName = authorData.authorFirstName;
                    self.authorLastName = authorData.authorLastName;
            });
            return record;
        }
    });
    return service;
}])
.controller('booksController', ['$scope', '$firebaseArray', 'normalizedBook', function($scope, $firebaseArray, normalizedBook) {
    $scope.bookSelected = new normalizedBook(firebaseService.refBooks.child(id);    
    $scope.updateBookSelected = function(item) {
        $scope.bookSelected.$save(item);
    };
});
我的视图呈现预期对象(同一对象中的书籍和作者信息),因此一切正常。唯一的问题是如何将我的对象更新回firebase数据库。你知道怎么做吗