There is a link to the working plunker .
The logic of the UI-Router
is how to find the target / binding for the view: always try to insert child
into parent
. If this is not possible, use absolute naming. cm:
So what I changed is that the parent unnamed view now contains the target / anchor for the child - the unnamed view <ui-view />
:
.state('root', { abstract: true, views: { '@': { template: '<ui-view />',
Also, since we are saying that the default URL is
$urlRouterProvider.otherwise('/home');
we must have this condition:
.state('root.home',{ parent:'root', url:'/home',
Check here
Another approach with plunker here , can target the root view in the child:
.state('root.home',{ parent:'root', url:'/home', views: { '@': { templateUrl:'home.html', controller: 'HomeController', controllerAs:'homeCtrl' } },
In this case, the parent state should not have <ui-view />
- we target the root, but we donโt inherit anything ... Why? See this link: