ui-router icon indicating copy to clipboard operation
ui-router copied to clipboard

Abstract state not allowing child states to load

Open alenb opened this issue 10 years ago • 1 comments

Going to /auth/register will force /auth/login to load instead. No matter what you do it will always hit /auh/login.

HTML:

<div ui-view="app"></div>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.15/angular-ui-router.js"></script>

JS:

var app = angular.module('app', ['ui.router']);
app.config(function($stateProvider, $urlRouterProvider, $locationProvider) {
    $locationProvider.html5Mode(true);
    $stateProvider
    .state('auth', {
        abstract: true,
        url: '/auth',
        views: {
            'app': {
                templateUrl: '/partial/auth/login'
            }
        }
    })
    .state('auth.register', {
        url: '/register',
        views: {
            'app': {
                templateUrl: '/partial/auth/register'
            }
        }
    })
    .state('auth.login', {
        url: '/login',
        views: {
            'app': {
                templateUrl: '/partial/auth/login'
            }
        }
    });
});

alenb avatar Jan 03 '16 01:01 alenb

You need to add 'app@' to target the named view above the parent

eddiemonge avatar Jan 04 '16 19:01 eddiemonge