I'm using ui-router for the following purpose:
1. I want load a layout template(such as left-right layout).
2. I want make left a root state, that mean's I only want change the right part.
3. I reuse this layout template(load different root state and right parts)
Here is the plunker: plunker. To archieve this, I made index.html, it has a ui-view, can load layout template. I made layout.html. then, left.html and right.html for root state and content.
app.js
app.config(['$stateProvider',
function($stateProvider) {
$stateProvider
.state("layout", {
url: '',
templateUrl: 'layout.html'
})
.state("layout.frame", {
url: '/frame',
views: {
left: {
controller: 'LeftCtrl',
templateUrl: "left.html"
}
}
})
.state("layout.frame.right1", {
url: '/right1',
views: {
'right@': {
controller: 'RightCtrl',
templateUrl: "right1.html"
}
}
})
.state("layout.frame.right2", {
url: '/right2',
views: {
'right@': {
controller: 'RightCtrl',
templateUrl: "right2.html"
}
}
});
}
]);
run plunker, click 'left', will show left.html, that great, but click 'right1' won't load right1.html(althought seeing from brower network, right1.html is loaded)
How can I make right1.html be loaded with root state not reload?
P.S. for root state, I refered this question angularjs ui-router - how to build master state which is global across app
I made a one layer nesting version(index1.html), it runs perfectly, but it doesn't support layout templating.
Thanks in advance.