Mean Stack: How To Update A Function's Result To The Database?
I'm having a commenting system and I need to store the upvotes in the database whenever the upvote icon is clicked. The function I have increases the number but as soon as I refres
Solution 1:
You need to create a c.update(comment)
method in your service that takes a comment to update and then calls a corresponding $http.put()
method in your API to update the comment when the upvote button is clicked.
Update: One more potential issue - if you are not specifically creating a comment.upvotes
property and setting it to 0 by default then your comment.upvotes += 1
might be adding one to null
or undefined
and not really adding one.
Post a Comment for "Mean Stack: How To Update A Function's Result To The Database?"