Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
168
rated 0 times [  173] [ 5]  / answers: 1 / hits: 15962  / 11 Years ago, thu, october 24, 2013, 12:00:00

I have the following problem to solve:



enter



From within local menu (menu on the left) I can choose sub pages. Typical scenario. And now I would like to relaod content associated with local menu item. In pure Angular I don't know a standard easy way to achieve it. I could get markup from the server manually and replace the content area manually. Is there a better way? I googled and came across




https://github.com/angular-ui/ui-router




Yet before I start delving into details perhaps you could advice how to solve this problem. Or even advice if I can solve this issue with ui-router.


More From » angularjs

 Answers
54

You want to use nested states in with ui-router. Something like this



$stateProvider
.state('home', {
templateUrl: 'views/home.html',
url: '/home',
controller: 'homeCtrl'
})
.state('home.localmenu1', {
templateUrl: 'views/localmenu1.html',
url: '/home/local1',
controller: 'local1Ctrl'
})
.state('home.localmenu2', {
templateUrl: views/localmenu2.html,
url: '/home/local2',
controller: 'local2Ctrl'
})
.state('products', {
templateUrl: 'views/products.html',
url: '/products',
controller: 'productsCtrl'
})


So inside your views/home.html you can put an element with the ui-view directive. Then this element will contain the views of the sub-states (home.localmenu1, home.localmenu2).


[#74761] Wednesday, October 23, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
collinisaaka

Total Points: 194
Total Questions: 105
Total Answers: 104

Location: Tonga
Member since Tue, Nov 30, 2021
3 Years ago
;