Note that there are some explanatory texts on larger screens.

plurals
  1. POAngular.js configuring ui-router child-states from multiple modules
    primarykey
    data
    text
    <p>I'd like to implement a setup where i can define a "root state" in the main module, and then add child states in other modules. This, because i need the root state to resolve before i can go to the child state.</p> <p>Apparently, this should be possible according to this FAQ: <a href="https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-ui-router-from-multiple-modules" rel="noreferrer">How to: Configure ui-router from multiple modules</a></p> <p>For me it doesn't work: <strong>Error</strong> Uncaught Error: No such state 'app' from ngBoilerplate.foo</p> <p>Here is what i have:</p> <p><strong>app.js</strong></p> <pre><code>angular.module( 'ngBoilerplate', [ 'templates-app', 'templates-common', 'ui.state', 'ui.route', 'ui.bootstrap', 'ngBoilerplate.library' ]) .config( function myAppConfig ( $stateProvider, $urlRouterProvider ) { $stateProvider .state('app', { views:{ "main":{ controller:"AppCtrl" } }, resolve:{ Auth:function(Auth){ return new Auth(); } } }); $urlRouterProvider.when('/foo','/foo/tile'); $urlRouterProvider.otherwise( '/foo' ); }) .factory('Auth', ['$timeout','$q', function ($timeout,$q) { return function () { var deferred = $q.defer(); console.log('before resolve'); $timeout(function () { console.log('at resolve'); deferred.resolve(); }, 2000); return deferred.promise; }; }]) .run(function run( $rootScope, $state, $stateParams ) { console.log('greetings from run'); $state.transitionTo('app'); }) .controller( 'AppCtrl', function AppCtrl ( $scope, Auth ) { console.log('greetings from AppCtrl'); }); </code></pre> <p><strong>foo.js</strong></p> <pre><code>angular.module( 'ngBoilerplate.foo', ['ui.state']) .config(function config( $stateProvider ) { $stateProvider .state( 'app.foo', { url: '/foo/:type', views: { "main": { controller:'FooCtrl', templateUrl: function(stateParams) { /* stuff is going on in here*/ } } } }); }) .controller( 'FooCtrl', function FooCtrl( $scope ) { console.log('deferred foo'); }); </code></pre> <p>How do i make this work or what other approaches could i take to have something global resolved before every state (without defining a resolve on each state)?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload