I have a list created using ng-repeat, with each item containing a count variable. There is also a link in each list item.
My goal is to increase the count when I click on the link.
I attempted the following approach but it did not work as expected.
This is my Controller code:
myApp.controller('allpost', function ($scope, $http, $stateParams, Allposts) {
var id = $stateParams.id;
Allposts.GetAllposts(id).then(
function (response) {
$scope.allPosts = response.data.posts;
});
function ctrl($scope) {
$scope.increment = function(item){
item.count += 1;
}
}
})
Here is how the view looks like:
<ion-content class="padding" lazy-scroll>
<div class="row no-padding HomeRowsList">
<div class="item itemfull" ng-repeat="post in allPosts">
<div class="item item-body">
<div>
<div class="title-news">
<div class="title" ng-bind-html="post.content"></div>
<div class="countbg">Number of times: {{post.custom_fields.azkarno}}</div>
<span>{{post.count}}</span><a ng-click="increment(post)">Increment</a>
</div>
</div>
</div>
</div>
</div>
</ion-content>