Parts of page as subviews in Angular

后端 未结 5 1599
傲寒
傲寒 2020-12-24 03:02

I have the following problem to solve:

\"enter

From within local menu (menu on

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-24 03:15

    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).

提交回复
热议问题