Skip to content

Frequently Asked Questions

Andy Joslin edited this page May 14, 2013 · 5 revisions

How to: Configure ui-router from multiple modules

How do I configure ui-router from multiple modules, it doesn't seem to get the same state provider?

What often goes wrong is dependencies. E.g:

angular.module('application', [...]).config(function ($stateProvider) {
    $stateProvider
        .state("feature1", { url : '/Feature1'...})
        .state("feature2", { url : '/Feature2'...});
});
angular.module('feature1', ['application', ...]).config(function ($stateProvider) {
    $stateProvider
        .state("feature1.home", {...})
        .state("feature1.detail", {...});
});

Note: Remember only to declare dependencies ones on module creation, so if you make several calls to angular.module for the same module, only the first should define dependencies.