title: Is there something like initialize module once in angular?
body: <p>Can I have loading some data once in angular module? I tried to use .run() but it gets called whenever page is accessed. For Example: say there are 2 html pages belonging to same module:</p>
  
  <pre><code>TestPage1.html:
  &lt;html ng-app="myApp"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
  &lt;script src="js/angular.min.js"&gt;&lt;/script&gt;
  &lt;script src="js/jquery-1.8.2.js"&gt;&lt;/script&gt;
  &lt;script src="js/app.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;p&gt;&lt;a ng-href="TestPage2.html"&gt;Go to Page2&lt;/a&gt;&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  TestPage2.html:
  &lt;html ng-app="myApp"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
  &lt;script src="js/angular.min.js"&gt;&lt;/script&gt;
  &lt;script src="js/jquery-1.8.2.js"&gt;&lt;/script&gt;
  &lt;script src="js/app.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;p&gt;&lt;a ng-href="TestPage1.html"&gt;Go to Page1&lt;/a&gt;&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  app.js:
  var myApp = angular.module('myApp', []);
  var cnt = 0;
  myApp.run(['$rootScope', '$http', function(scope, $http) {
  if(scope.loggedIn == undefined || scope.loggedIn == null) {
      $http.get('rest/userData').success(function(data) {
          cnt++;
          alert(cnt);
          scope.loggedIn = true;
  });
  }
  }]);
  </code></pre>
  
  <p>When I navigate from one page to another this .run() is getting called again and again with cnt as 1. Is it possible to have it called once in life- time of module getting initialized? Or what is the other way?</p>