I have an html element which I would like to update upon different actions.
HTML
<span>{{progress.mandates_transferred}}/{{progress.mandates_count}}</span>
js
this.app.controller('appController', ['MandateService', function(MandateService){
MandateService.progress($scope)
$scope.MarkDone = function() {
MandateService.progress($scope)
}
}])
this.app.service('MandateService' [
'$http',
function($http) {
var url = 'api/mandate'
return {
progress: function($scope) {
$http.get(url).success(function(data) {
$scope.progress = data
})
}
}}])
There is a click action markDone which calls the MandateService to update the $scope values
the value $scope.progress updates if I add a console.log in the service to check the values in $scope but it is not updated in the HTML. I have tried a few techniques mentioned but none of them help
I have tried adding $scope.$apply() but I get an error $digest already in progress sol1 sol2