3

My controllers are being fired twice when I refresh the page. However, if I navigate to the page from elsewhere in the app the controller just fires once, as expected. The issue only arises if I then refresh the page.

This is a similar issue to these two questions :

  1. Combating AngularJS executing controller twice

  2. AngularJs: controller is called twice by using $routeProvider

However, the issue I am facing is different in that I am only declaring my controller in the routeProvider config.

$routeProvider.when('/render/pools/', {
    templateUrl: "app/components/render/pools/views/pools.tpl.html",
    controller: "PoolsCtrl"
}); 

I'm inclined to believe that it is an issue with the routeProvider module and how I've configured it. I'm certain that my controllers are only being declared in the routeProvider config. I'm not using ng-controller at any point.

Any suggestions?

Community
  • 1
  • 1
abyrne85
  • 1,370
  • 16
  • 33
  • 1
    have you injected controller anywhere else? – RIYAJ KHAN Jul 13 '15 at 09:57
  • I really don't think so. Searching for "PoolsCtrl" through the whole project only has two results, the routeProvider and the controller itself. I don't know how to be more certain than that. – abyrne85 Jul 13 '15 at 10:07
  • why are you saying that its fired twice? share more relevant code – harishr Jul 13 '15 at 10:19
  • 1
    I actually discovered the source of the issue since the original post. We are calling a $route.reload on each page refresh as part of the user authentication process. – abyrne85 Jul 13 '15 at 10:57
  • check if you have declared ng-app twice, that could also make the controller to be called twice.... post more code, its difficult to tell what could be going wrong with the amount of code you have posted – akashrajkn Jul 13 '15 at 11:15

0 Answers0