Flezcano
Flezcano

Reputation: 1697

Resolve not firing in Angular ui-router

I am using resolve in $stateProvider. I am not sure why it is not even firing. Not even the controller is loaded. Also I am not getting any error on console. Am I missing something ?

var commonModule = angular.module('menaAdolescentFS.common',['ui.router'])
.config(function ($stateProvider, $urlRouterProvider) {

    $urlRouterProvider.otherwise("/offices")
        $stateProvider
        //.state('/', {
        //    url: '',
        //    template: ''
        //})
        .state('offices', {
            url: '/offices',
            templateUrl: 'Scripts/app/templates/offices.html',
            controller: 'officesController',
            resolve: {
                userSession : function(sessionService){
                    return sessionService.getUserSession();
                }
            }
        })
    });

Upvotes: 0

Views: 83

Answers (1)

Kyle Olson
Kyle Olson

Reputation: 121

  1. Similar to what Vivz said, make sure you're invoking the resolve by injecting it into your controller.
  2. Another common reason that resolves do not fire is because the state cannot find the templateUrl you are referencing. Make sure that template exists (typo or otherwise).

Upvotes: 1

Related Questions