当用户发布评论时,我正试图在我的应用程序中实现upvods。我可以将选票显示在我的视图中,但不知道如何将其保存到Firebase。
JS
var commentRef = new Firebase(FIREBASE_URL);
var commentsync = $firebase(commentRef);
$scope.messages = commentsync.$asArray();
$scope.addMessage = function(text, item, user, votes) {
$scope.messages.$add({text: text, item: $scope.item.link, user: Auth.user.email, votes: 0});
$scope.newMessageText = '';
};
$scope.voteUp = function(message) {
message.votes += 1;
$scope.messages.$save("votes");
};
HTML
<button ng-click="voteUp(message)"></button> ({{message.votes}})
在查看了位于https://www.firebase.com/docs/web/libraries/angular/guide.html#section-数组,它看起来像$scope.messages.$save("投票");应为$scope.messages.$save(message).