app.controller('MainController', ['$scope','forecast','location',function($scope,forecast,location) {
// this will bring data on page load
forecast.getData(function(data) {
//data bound to scope
$scope.testData = data;
});
//this will bring data on user click
$scope.sendLocation = function(){
//Here is the actual call... just put it on a button click.
location.save(function(successResult){
if(successResult.status === 200){
$scope.$eval( function() {
//data should bound to scope on user click
$scope.testData = successResult.data;
console.log($scope.testData);// successfully log new data to the console
});
};
/* $scope.$apply(); getting $digest already in progress error */
},function(err){
console.log(err);
});
}
}]);
Problem is that when i click, though console log the desired data but data is not updating on the DOM. As suggested in this post i used $scope.$apply() at the bottom my handler but that getting error , I also tried $scope.$eval and $timeout, though that do not give any error but at the same time both are not updating model