leaksterrr
leaksterrr

Reputation: 4167

UI Router default child view not activating

In my application I have two views, a parent view called content-box and a child view called child-content. child-content is tabbed content inside content-box. When a user lands on /settings I want the page to render the settings view in content-box and also load a default state in the tabbed content. I have the following code which just renders child-content as blank...

$stateProvider
    .state('silverstone.environment.settings', {
        url: '/settings',
        views: {
            'content-box': {
                controller: 'EnvironmentCtrl',
                template: require('./views/configuration.html')
            },
            'child-content': {
                controller: 'EnvironmentCtrl',
                template: require('./views/settings/general.html')
            }
        }
    });

Upvotes: 1

Views: 39

Answers (1)

Nikhil Aggarwal
Nikhil Aggarwal

Reputation: 28455

The views are siblings rather than parent child. You can update your code to following

$stateProvider
    .state('silverstone.environment.settings', {

        views: {
            'content-box': {
                controller: 'EnvironmentCtrl',
                template: require('./views/configuration.html')
            }

        }
    }).state('silverstone.environment.settings.view', {
        url: '/settings',
        views: {

            'child-content': {
                controller: 'EnvironmentCtrl',
                template: require('./views/settings/general.html')
            }
        }
    });

Upvotes: 1

Related Questions