Routing Wierdness In Angular With Ui-routing
Another question guys :) If I leave the templateUrl empty in my routing, the scope is queriable but no template showing. But if I write it just as in the linked plunker project, it
Solution 1:
There is an updated plunker
I am not fully sure what you want to do with your root state, so I used it the way I do...
$stateProvider
.state('root', {
abstract: true,
template: '<div ui-view=""></div>',
resolve: {
somedata: function(){return {}}
}
})
.state('home', {
parent: 'root',
url: '/home',
templateUrl: 'listView.html',
controller: 'ListController'
})
.state('about', {
parent: 'root',
url: '/about',
templateUrl: 'resumeView.html'
})
.state('items', {
parent: 'root',
url: '/items/:itemLink',
templateUrl: 'itemView.html',
controller: 'ItemController'
});
As we can see, super parent state 'root'
is not having url defined, and it does contain template (where all children be injected)
On the other hand, every state now declares its parent as a 'root'. It will mean, that all states do have access to resolves or any other common stuff later applied to root.
Easy way how to effect all states.. Hope this could help. Maybe check this for some more details: Angular JS - UI router page reload won't set the state
Post a Comment for "Routing Wierdness In Angular With Ui-routing"