The controller.js file is given as
function XYZController($rootScope,$scope){
var vm = this;
vm.a = 0;
var change = function(data){
data.forEach(function(e,i){
vm.a+=Number(e.value);
});
}
$log.log(vm.a);
}
The function change is called,but the $log.log(a) prints 0,instead of the updated sum.How to take the updated value of vm.a?When I do $scope.$apply,I get an error "$digest is already in progress".
change? Please post all the relevant code.