user2820445
user2820445

Reputation: 101

Angular UI Router - nested routes does not work on templates with nested state

Here is my code:

.state('profile',{ 
        url : '/profile',
        templateUrl: 'views/user.html', 
        controller: 'UserCtrl'
      })
      .state('profile.forgot',{ 
        url : '/delivers',
        templateUrl: 'views/user_forgot.html', <- this template not appear, when state is active
        controller: 'forgotCtrl'
      })

<a ui-sref="profile.forgot">Forgot your pasword?</a>
<div class="panel" ui-view=""></div>

When i click on link, in ui-view appeared template and controller of parent state. AngularJS version is 1.2.0-rc.2

Upvotes: 10

Views: 6356

Answers (2)

Ayush
Ayush

Reputation: 518

Please Pay attention to parent-child naming convention!

.state('profile.forgot',{ 
        url : '/forgot',
        templateUrl: 'views/profile.forgot.html',
        controller: 'forgotCtrl'
      })

Upvotes: -2

Phil Thomas
Phil Thomas

Reputation: 1237

A nested state will render within the ui-view element of its parent template (which, if parentless, renders within the root ui-view). Make sure you read the 'Nested States & Views' section of the docs.

Upvotes: 7

Related Questions