12

I'm working on an application built with AngularJS that has two different states:

  1. App intro wizard
  2. App pages (with a Navigation template and nested views)

I want to default to State 1 the first time someone access the app, once done the wizard, continue on to the App pages, State 2.

My "app" state (State 2) is an abstract state because it has nested views. So I cannot transition to this state.

.config(function($stateProvider, $urlRouterProvider) {
$stateProvider

  .state('intro', {
    url: '/',
    templateUrl: 'templates/intro.html',
    controller: 'IntroCtrl'
  })

  .state('app', {
    url: '/app',
    abstract: true,
    templateUrl: 'templates/menu.html',
    controller: 'AppCtrl'
  })

  .state('app.playlists', {
    url: "/playlists",
    views: {
      'menuContent' :{
        templateUrl: "templates/playlists.html",
        controller: 'PlaylistsCtrl'
      }
    }
  });

  $urlRouterProvider.otherwise("/");

})
4
  • So transition to one of the child states? And/or do something like this: $urlRouterProvider.when('/app', '/app/playlists'); Commented Apr 4, 2014 at 18:01
  • @aet I tried this, but since my app State is using a side menu template, going directly to app/playlists didn't load in the menu. Commented Apr 4, 2014 at 22:07
  • @MarkK got the same issue any fixed solution for this. I'm trying to integrate Ionic Intro Tutorial with Splashscreen(codepen.io/gwhickman/pen/zpDFG) with side menu application getting the problem. Commented May 19, 2016 at 17:15
  • @VinodKumarMarupu Unfortunately, not. I had scrapped that flow and reworked the onboarding to my app. Commented May 24, 2016 at 13:32

3 Answers 3

14

I've got the same problem as you, here is a post about abstract state: angularjs ui-router default child state and ui-sref

It explains why you can't directly access abstract state

Hope it helps.

Sign up to request clarification or add additional context in comments.

Comments

3

I have added $location service to the controller of the "intro" page and use the following to transit to app state which works for me.

$location.path('app/playlists');

The menu.html is loaded and navigated to playlists.

Comments

0

In a service:

$location.path(
    $state.href('app.some.abstract.state', { some: 'params' })
);

Or in a template ($state must be available in the local or global $scope):

<a ng-href="{{$state.href('app.some.abstract.state', { some: 'params' })}}">...</a>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.