1

I have code that detects routing in controller Angular JS:

$scope.$on('$routeChangeSuccess', function() {
     if($routeParams.user){
       // AJAX 
     }
});

When I am on page with URL for this routing and do new AJAX request then the previous code is executed again. How to disable repeating executable?

samjewell
  • 1,068
  • 11
  • 20
Xakerok
  • 233
  • 1
  • 2
  • 8
  • you can disable the event like this: `var stopListen = $scope.$on('yourEvent', callbackFn); stopListen();` ... but that is not a temporary solution, it will disable the event completely, so you'll have to reset it somehow in case if you intend to use it again. [angular docs](https://docs.angularjs.org/api/ng/type/$rootScope.Scope) – ZenDD Oct 04 '15 at 19:03
  • This solution helped me http://stackoverflow.com/a/20456677/5403949 – Xakerok Oct 04 '15 at 19:07

0 Answers0