Ionic ng-click导航到状态删除左侧的菜单

时间:2017-02-03 13:25:25

标签: html angularjs ionic-framework

我有以下菜单模板 以下<ion-side-menus>位于template/menu/menu.html

<ion-side-menus>
    <ion-side-menu-content>
        <ion-nav-bar class="bar-stable nav-title-slide-ios7">
            <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" animation="slide-left-right"></ion-nav-view>
    </ion-side-menu-content>    

    <ion-side-menu enable-menu-with-back-views="true" side="left">
        <ion-header-bar class="bar-assertive">
            <h1 class="title">Menu</h1>
        </ion-header-bar>
        <ion-content>
            <div ui-view="leftMenuContent"></div>
        </ion-content>
    </ion-side-menu>
</ion-side-menus>

使用以下技术从html文件导航时

<ion-view view-title="Nutrition">
    <ion-content class="padding">
     <button class="button button-full button-calm" ng-click="viewPlans()">Plans
     </button>
</ion-content>
</ion-view>

home.controller('NutritionController', function ($state) {

    $scope.viewPlans = function () {
      $state.go('app.home.nutrition.plan');
    };
});

<ion-side-menus>被完全删除并替换为从状态加载的内容,即只有一个屏幕,左边没有菜单。

使用以下技术从html文件导航

<ion-view view-title="Nutrition">
    <ion-content class="padding">
       <a ui-sref="app.home.nutrition.plan" class="button button-full button-calm" menu-close>Plans</a>
    </ion-content>
</ion-view>

左边的菜单只关闭,内容会加载到菜单的内容部分。

以下是我的路线:

.state('app', {
            url: '',
            abstract: true,
            templateUrl: 'template/menu/menu.html',
            controller: 'MainCtrl as mainCtrl'
})
.state('app.home', {
    url: '/home',
    views: {
        'menuContent@app': {
            templateUrl: 'template/home.html',
            controller: "HomeController as homeCtrl"
        },
        'leftMenuContent@app': {
            templateUrl: 'template/menu/left/main.html',
            controller: "HomeController as homeCtrl"
        }
    }
})
.state('app.home.nutrition', {
    url: '/nutrition',
    views: {
        'menuContent@app': {
            templateUrl: 'template/nutrition.html',
            controller: "NutritionController as nutritionCtrl"
        },
        'leftMenuContent@app': {
            templateUrl: 'template/menu/left/nutritionMenu.html'
        }
    }
})
    .state('app.home.nutrition.plan', {
        url: '/plan',
        views: {
            'menuContent@app': {
                templateUrl: 'template/plan/plan.html',
                controller: "PlanController as planCtrl"
            },
            'leftMenuContent@app': {
                templateUrl: 'template/menu/left/planMenu.html'
            }
        }
    });

在进行ng-click时,有没有办法让菜单保持在左边?

0 个答案:

没有答案