简体   繁体   中英

How have in AngularJS with UI Router, multiple and nested views?

I have been reading about nested views and multiple views but I can't find an example using both

In a landing page I have multiple views, one after other. A picture speaks a thousand words: 在此处输入图片说明

To consider:

  • Every section/view will have full window height, so on scroll I want to change location to /view1 , /view2 , /view3 , etc.
    • That should be compatible with going to /view1/b or /view3/b and showing subview ( view1.b or view3.b ).
    • Scroll should not make load page again.

I have success doing tasks separately but not all together.

you can use $statePorivder nested view with

       config(function ($stateProvider) {

            $stateProvider
              .state('main', {
                url: '/',
                views: {
                  '': {
                    templateUrl: 'app/main/layout.html',
                    controller: 'LayoutController'
                  },
                  'header@main': {
                    templateUrl: 'app/main/header/layout.html',
                    controller: require("./headerController.js")
                  },
                  'left@main': {
                    templateUrl: 'app/main/left/layout.html',
                    controller: require("./leftController.js")
                  },
                  'content@main': {
                    templateUrl: 'app/main/content/layout.html',
                    controller: require("./conentController.js")
                  },
                  'right@main': {
                    templateUrl: 'app/main/right/layout.html',
                    controller: require("./rightController.js")
                  }
                }
              });
          };

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM