I have an image gallery which contains a photo, a thumbs-up button and a progress bar for each item. All items are derived from only one JSON object. I want to dynamically change my progress bar according to how many times the thumbs-up button is clicked.
<div class="container col-lg-12">
<h2>Vote for your favorite character</h2>
<div class="progress" >
<div class="progress-bar" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" ng-style="{width:{{width(character.likes)}}+'%'}">
</div>
</div>
</div>
<input style="width:10%;height:10%" type="image" value="like" ng-click="incrementLikes(character)" src="images/thumbs-up.png"/>
<input style="width:10%;height:10%" type="image" value="dislike" ng-click="decrementLikes(character)" src="images/thumbs-down.png"/>
My issue is that the progress bar will not update no matter how many times the button is clicked.
$scope.incrementLikes = function(character) {
character.likes++;
}
$scope.decrementLikes = function (character) {
character.likes--;
}
$scope.width = function(likes) {
if (likes >= 0) {
return likes+10;
}else{
return 0;
}
}
Any ideas?