我已经坚持这个问题一个星期了,我觉得我理解'ui-router'和'ionic's'视图路由,但似乎并非如此 .

我已经看到了很多关于视图如何工作的示例,但是现在我的构建体积更大,我看到的示例对于我的项目来说太简单了,因为我的项目包含侧边菜单,选项卡和每个选项卡内容的视图 .

My issue:

我在我的标签内持有不同控制器的多个视图 . 我正在使用传单 Map 和下拉列表,这些列表将填充我的位置,我两个都可以工作 . 但是,这些观点正在进行奇怪的调用 . 我随时选择传单 Map ,它会在我的 menu.html 中的应用程序 ion-nav-bar 下按下我的"Discover List"(在我的 discover-home.html 中)按钮 . 此外,您可以看到此列表视图位于我的 Map 和缩放图标之间,如果不触摸我的 Map ,我切换标签并返回我无法再次打开列表 .

I think 我需要问的问题是了解我的问题

1. What is the correct way to navigate in a multi-viewed applications using ionic's view navigation?

2. Why does changing views disable other controllers from being called again?

3. What are some of the best practices?

这就是我正在处理的问题 . 任何帮助,将不胜感激 .

我的标签视图里面的discover-home.html侧边栏视图里面的menu.html列表显示在discover-home.html发现列表中的discover-home.html隐藏在menu.html中的ion-nav-bar下面

Here's my code snippets

index.html

<body ng-app="starter">
     <ion-nav-view></ion-nav-view>
  </body>

discover-tabs-controller.html

这将控制选项卡视图(其中一个是discover-home.html)

<ion-view>
      <div class="tabs-striped tabs-top tabs-background-positive tabs-color-light">

    <ion-tabs class="tabs-positive tabs-icon-only" >
     <ion-content  has-subheader="true"></ion-content>

<!--HOME TAB [OPEN]-->
    <ion-tab title="Discover" icon-on="icon ion-home" icon-off="icon ion-home" 
      href="#/app/discover/home">

      <ion-nav-view cache-view="true" name="home-tab"></ion-nav-view>
        <!-- View For Home.html -->
      </ion-tab>
 <!--HOME TAB [CLOSED]-->  


     <!--MORE TABS HERE-->

    </ion-content>
    </ion-tabs>
      </div>
    </ion-view>

Discover-home.html

<ion-view view-title="Home">


<!--SUBHEADER BUTTON: DISPLAY LISTVIEW -->
    <div ng-controller="FrostCtrl" class="bar bar-subheader button bar-balanced" ng-click="pushFrost()">
        <h2 class="title">{{title}} List</h2>
    </div>



  <!--DISPLAY OVERLAY WITH LIST-->
    <ion-pane ng-controller="OverlayCtrl" class="dark-overlay" ng-show="showOverlay">

      <ion-content class="has-subheader">

        <button class="button button-block button-outline button-balanced" ng-click="hideFrost()">Dismiss
        </button>

        <ion-list>
            <ion-item ng-repeat="item in items" class="dark-item">
              {{item.text}}
           </ion-item>
        </ion-list>

        </ion-content>
    </ion-pane>




  <!--LEAFLET MAP -->
    <leaflet class="has-subheader padding"center="nassau" paths="paths" tiles="tiles" markers="markers" defaults="defaults">
      </leaflet>


</ion-view>

controller.js

angular.module('starter.controllers', [])
            ...


    // #######| LEAFLET MAP  |#######
        .controller('ActivityCntl', [ '$scope', 'leafletData', function($scope, leafletData) {

           var tileSource = {
                onlineTiles: {
                    url: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" 
                },

            };

            angular.extend($scope, {

                nassau: {
                lat: 25.074521,
                lng: -77.318191,
                zoom: 13
                .........
            });
        }])


  // #######| SHOW OVERLAY  |#######
        .controller('FrostCtrl', ['$scope', '$rootScope', '$compile', function($scope, $rootScope, $compile) {
          $scope.pushFrost = function() {
            var el = angular.element(document.getElementById('myPane'));
            el.attr('frost', '');
            el = $compile(el)($scope);
            $rootScope.showOverlay = true;
          };
        }])


    //#######| DISPLAYS CONTENTS |##########
        .controller('OverlayCtrl', function($scope, $rootScope, $compile) {
          $scope.items = [];
          for(var i = 0; i < 5; i++) {
            $scope.items.push({

              text: 'Whatever ' + (i+1)

               });
          }
          $scope.hideFrost = function() {
            $rootScope.showOverlay = false;
            var el = angular.element(document.getElementById('myPane'));
          };
        })

app.js

config(['$stateProvider', '$urlRouterProvider','$locationProvider',function($stateProvider, $urlRouterProvider, $locationProvider) {
  $stateProvider

.state('app', {
    name: 'app',
    url: "/app",
    abstract: true,
    templateUrl: "templates/menu.html",
    controller: 'AppCtrl'
  })

.state('app.discover', {
    name: 'app.discover',
    url: "/discover",
    views: {
      'menuContent': {
        templateUrl: "templates/discover-tabs-controller.html"
      }
    }
  })

// for my discover-home.html .state('app.discover.home',{

url: "/home",
views: {
   'home-tab': {
   templateUrl: "templates/discover-tabs/discover-home.html",
   controller:  'ActivityCntl'
       },
       'discover-home-listview': {
   templateUrl: "templates/discover-tabs/discover-home.html",

       }
}

})

菜单

这可以控制侧面菜单项

<ion-side-menus enable-menu-with-back-views="false">
      <ion-side-menu-content>

//IT GETS PUSHED UNDER THIS
        <ion-nav-bar class="bar-calm">
          <ion-nav-back-button>
          </ion-nav-back-button>

          <ion-nav-buttons side="left">
            <button class="button button-icon button-clear ion-navicon" menu-toggle="left">
            </button>
          </ion-nav-buttons>
        </ion-nav-bar>
        <ion-nav-view name="menuContent"></ion-nav-view>
      </ion-side-menu-content>

      <ion-side-menu side="left">
        <ion-header-bar class="bar-stable">
          <h1 class="title">MYApps</h1>
        </ion-header-bar>
        <ion-content>
          <ion-list>
            <ion-item menu-close ng-click="login()">
            <i class="icon ion-person"></i>
              Login
            </ion-item>
            <ion-item menu-close href="#/app/discover">
             <i class="icon ion-location"></i>
              Discover
            </ion-item>
            <ion-item menu-close href="#/app/map">
            <i class="icon ion-map"></i>
              Map
            </ion-item>

          </ion-list>
        </ion-content>
      </ion-side-menu>
    </ion-side-menus>