简体   繁体   English

带有UI Router的AngularJS中如何包含多个视图和嵌套视图?

[英]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. 每个部分/视图都将具有完整的窗口高度,因此在滚动时,我想将位置更改为/view1/view2/view3等。
    • That should be compatible with going to /view1/b or /view3/b and showing subview ( view1.b or view3.b ). 那应该与转到/view1/b/view3/b并显示子视图( view1.bview3.bview3.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 您可以将$ statePorivder嵌套视图与

       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")
                  }
                }
              });
          };

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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