1

Here is plnkr: http://plnkr.co/edit/wfIFA01kfG1zggsPo7Q9

I have one abstract parent state 'app' and two child states 'app.home' and 'app.signin'. Parent state has to resolve some asynchronous stuff.

app.core:

  $stateProvider
    .state('app', {
      url: '',
      abstract: true,

      // has to be resolved by any child state, except app.auth
      resolve: {
        Something: function($http) {
          // real delay
          return $http.get('http://httpbin.org/delay/5');
        }
      }
    });

app.home:

  $stateProvider
    .state('app.home', {
      url: '/home',
      views: {
        'main@' : {
          template: '<div>I am home page</div> <a ui-sref="app.signin">Sign in</a>'
        }
      }
    });

app.signin

  $stateProvider
    .state('app.signin', {
      url: '/',
      views: {
        'main@' : {
          template: '<div>I am signin page </div> <a ui-sref="app.home">Home page</a>'
        }
      }
    });

I want any child state require Something too, except app.signin. How can I do that?


Also worth to mention, I do not describe any resolvers at my child states. But they still wait till the parent is done, and I thought that (quote from ui-router doc):

The resolve keys MUST be injected into the child states if you want to wait for the promises to be resolved before instantiating the children.

And I dont know why child states still resolving parent`s dependency.

5
  • You could create another abstract state from which app.signin will depend. Have you tried that? Commented Mar 26, 2015 at 14:07
  • I thought about that. It may solve my problem, but I would like to leave the things as they are and change app.signin state somehow in order to be able ignore parent`s resolver. Commented Mar 26, 2015 at 14:16
  • I'm fairly sure that the wiki documentation is incorrect... I do not believe that resolve keys must be injected. Commented Mar 27, 2015 at 11:31
  • I have found some relevant issues: issue#868 and issue#1761. There are some clarifications in them, but the problem still exists. Commented Mar 27, 2015 at 13:53
  • @RobsonGilli, I gave up. I am no longer looking for solution with single root state. I decided to divide my application on public and private parts as you suggested. So you may post your answer and I will accept it. Thanks. Commented Mar 30, 2015 at 8:58

1 Answer 1

0

So the ideia is to create another abstract state from which app.signin will depend on. This plunker demonstrate that(fork from your plunker): http://plnkr.co/edit/kpfbylbBTVX8Erm5cgoF?p=preview

(function() {
  'use strict';
  angular
    .module('app.auth', [
      'app.core'
    ])
    .config(function ($stateProvider) {
      $stateProvider
      .state('app2', {
          url: '',
          abstract: true
        })
        .state('app2.signin', {
          url: '/',
          views: {
            'main@' : {
              template: '<div>I am signin page </div> <a ui-sref="app.home">Home page</a>'
            }
          }
        });
    });
})();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.