Hi I'm want to load data from a factory before any of my controllers are loaded. I found a way to do it using resolve:
angular.module('agent', ['ngRoute','ui.bootstrap','general_module', 'order_module','customer_module']).config(['$routeProvider', function($routeProvider) {
  $routeProvider.when('/customer', {
    templateUrl: 'customer_module/partials/customer.php',
    resolve:{
      'MyServiceData':function(loginvalidation){
        // MyServiceData will also be injectable in your controller, if you don't want this you could create a new promise with the $q service
       var a=loginvalidation.check_usertype();
      }}
    }
    );
  $routeProvider.otherwise({redirectTo: '/customer'});
}]);
But the problem is I would have to duplicate this with every single route. Is there a way in angularjs to write the code once to load the service before any controller is initiated (without duplicating my code)?
Thanks
 
    