I have an array of posts:
.factory('posts', [function(){
var o = {
posts: [
{title: 'post 1', upvotes: 5},
{title: 'post 2', upvotes: 2},
{title: 'post 3', upvotes: 15}
]
};
return o;
}])
and a Controller. I would like to edit all upvotes when clicking a button, so I have the following.
angular.forEach($scope.posts, function(title){
$scope.posts.push({
title: "ja"
});
});
but obviously this is creating new posts. anyone knows how to edit the existing ones? thanks