How do I setup nested views in AngularJS?

后端 未结 2 1369
我在风中等你
我在风中等你 2020-12-13 13:12

I have an application with various screens. Each screen is assigned a URL, such as #, mails, contacts, and so on.

In

相关标签:
2条回答
  • 2020-12-13 13:26

    Another library to check out: http://angular-route-segment.com

    You can use it instead of built-in ng-view and $route.

    Sample route config looks like this one:

    $routeSegmentProvider.
    
    when('/section1',          's1.home').
    when('/section1/prefs',    's1.prefs').
    when('/section1/:id',      's1.itemInfo.overview').
    when('/section1/:id/edit', 's1.itemInfo.edit').
    when('/section2',          's2').
    
    segment('s1', {
        templateUrl: 'templates/section1.html',
        controller: MainCtrl}).
    
    within().
    
        segment('home', {
            templateUrl: 'templates/section1/home.html'}).
    
        segment('itemInfo', {
            templateUrl: 'templates/section1/item.html',
            controller: Section1ItemCtrl,
            dependencies: ['id']}).
    
        within().
    
            segment('overview', {
                templateUrl: 'templates/section1/item/overview.html'}).
    
            segment('edit', {
                 templateUrl: 'templates/section1/item/edit.html'}).
    
            up().
    
        segment('prefs', {
            templateUrl: 'templates/section1/prefs.html'}).
    
        up().
    
    segment('s2', {
        templateUrl: 'templates/section2.html',
        controller: MainCtrl});
    
    0 讨论(0)
  • 2020-12-13 13:43

    AngularJS ui-router solved my issues :-)

    0 讨论(0)
提交回复
热议问题