简体   繁体   English

在单个页面中显示多个视图

[英]Ionic Showing multiple viewes in a single page

I m using Ionic to build an application. I 我正在m using Ionic to build an application. I m using Ionic to build an application. I m new to Ionic and i would like some help in setting up my view. m using Ionic to build an application. I是Ionic的新手,我需要一些帮助来建立我的观点。

my app contains an abstract main view which contains the main header 我的应用程序包含一个抽象的主视图,其中包含主标题

<script type="text/ng-template" id="main-view">
    <ion-header-bar class='bar bar-header bar-stable' align-title="center">
        <h3 class="title">Title</h3>
    </ion-header-bar>
    <ion-nav-view name="View-A"></ion-nav-view>
    <ion-nav-view name="View-B"></ion-nav-view>
</script>

and another view which supposed to be like a split screen. 另一个应该是分割屏幕的视图。 basicly i`m trying to show 2 views on the same page (with different controllers) 基本上我想在同一页面上显示2个视图(使用不同的控制器)

this is my config: 这是我的配置:

.config(function ($stateProvider, $urlRouterProvider) {
    $stateProvider
    // setup an abstract state for the tabs directive
      .state('main', {
          url: '/main',
          abstract: true,
          templateUrl: 'main-view'
          }

      })
    .state('main.inner', {
        url: '/inner',
        views: {
            'View-A': {
                templateUrl: "View-A",
                controller: 'ViewACtrl'
            },
            'View-B': {
                templateUrl: 'View-B',
                controller: 'ViewBCtrl'
            }
        }
    });

    $urlRouterProvider.otherwise('/main/inner');

})

The views look like this 视图看起来像这样

<script type="text/ng-template" id="View-A">
    <ion-view>
<-- DATA -->
 </ion-view>
</script>

<script type="text/ng-template" id="View-B">
    <ion-view>
<-- DATA -->
 </ion-view>
</script>

The Problem is, that only the second view is shown. 问题在于,仅显示了第二个视图。 what am i doing wrong? 我究竟做错了什么?

Try to replace 尝试更换

<ion-nav-view name="View-A"></ion-nav-view>
<ion-nav-view name="View-B"></ion-nav-view>

with

<div ui-view="View-A"></div>
<div ui-view="View-B"></div>

EDIT 编辑

There is an option to use this library . 有使用该的选项。 Add 'ionicMultipleViews' to angular.module and it should work. 将“ ionicMultipleViews”添加到angular.module,它应该可以工作。

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

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