1

On first load to detail page works fine. But if I go to different page and come back to the detail page $http.get doesn't get new data(it doesn't hit the MVC controller). It shows the same result as in previous time.

------------Detail Page------------------------

<div ng-controller="mycontroller" ng-init="loadPage()"></div>

-----------Controller------------------

myapp.controller("mycontroller", ["$scope", function($scope){
    $scope.loadPage= function(){
       $http.get("url").success(function(data){
          $scope.data = data;
}}}]);
Bizzu
  • 66
  • 4
  • Any chance you set up a cache in your app settings ? – Or Duan Apr 29 '16 at 20:24
  • Thanks. It worked by disabling cache. I found a solution here http://stackoverflow.com/questions/12948156/asp-net-mvc-how-to-disable-automatic-caching-option – Bizzu Apr 29 '16 at 20:58

1 Answers1

0

EDIT: Work-around to avoid $digest already in progress error.

Add

if (!$scope.$$phase) { $scope.$apply(); }

in your function

Nishant Roy
  • 1,043
  • 4
  • 16
  • 35
  • ... and it will throw nice "$digest already in progress" error. – dfsq Apr 29 '16 at 20:27
  • True... I used it and I got the $digest error, but it still worked. I was told to use `$timeout()` which apparently should have an implicit `$scope.apply()` at the end, but that didn't work. – Nishant Roy Apr 29 '16 at 20:39