mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
hide toolbar menu-toggle when not the root
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import {Directive} from 'angular2/angular2';
|
||||
import {Directive, Optional} from 'angular2/angular2';
|
||||
|
||||
import {IonicApp} from '../app/app';
|
||||
import {ViewItem} from '../view/view-item';
|
||||
import {Navbar} from '../nav-bar/nav-bar';
|
||||
|
||||
|
||||
/**
|
||||
* TODO
|
||||
@@ -11,12 +14,17 @@ import {IonicApp} from '../app/app';
|
||||
'menuToggle'
|
||||
],
|
||||
host: {
|
||||
'(click)': 'toggle($event)'
|
||||
'(click)': 'toggle($event)',
|
||||
'[hidden]': 'isHidden'
|
||||
}
|
||||
})
|
||||
export class MenuToggle {
|
||||
|
||||
constructor(private app: IonicApp) {}
|
||||
constructor(app: IonicApp, @Optional() item: ViewItem, @Optional() navbar: Navbar) {
|
||||
this.app = app;
|
||||
this.item = item;
|
||||
this.withinNavbar = !!navbar;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
@@ -28,4 +36,12 @@ export class MenuToggle {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
}
|
||||
|
||||
get isHidden() {
|
||||
if (this.withinNavbar && this.item) {
|
||||
return !this.item.isRoot();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,23 @@
|
||||
import {App, IonicApp, IonicView} from 'ionic/ionic';
|
||||
import {App, IonicApp, IonicView, NavController} from 'ionic/ionic';
|
||||
|
||||
|
||||
@IonicView({templateUrl: 'page1.html'})
|
||||
class Page1 {}
|
||||
|
||||
|
||||
@IonicView({templateUrl: 'page3.html'})
|
||||
class Page3 {}
|
||||
|
||||
|
||||
@IonicView({templateUrl: 'page2.html'})
|
||||
class Page2 {}
|
||||
class Page2 {
|
||||
constructor(nav: NavController) {
|
||||
this.nav = nav;
|
||||
}
|
||||
page3() {
|
||||
this.nav.push(Page3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@App({
|
||||
@@ -21,6 +32,7 @@ class E2EApp {
|
||||
this.pages = [
|
||||
{ title: 'Page 1', component: Page1 },
|
||||
{ title: 'Page 2', component: Page2 },
|
||||
{ title: 'Page 3', component: Page3 },
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -19,4 +19,8 @@
|
||||
<button menu-toggle id="e2eContentToggleMenu">Toggle Menu</button>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<button (click)="page3()">Go to page 3</button>
|
||||
</p>
|
||||
|
||||
</ion-content>
|
||||
|
||||
25
ionic/components/menu/test/basic/page3.html
Normal file
25
ionic/components/menu/test/basic/page3.html
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
<ion-navbar *navbar>
|
||||
|
||||
<a menu-toggle>
|
||||
<icon menu></icon>
|
||||
</a>
|
||||
|
||||
<ion-title>
|
||||
Menu
|
||||
</ion-title>
|
||||
|
||||
</ion-navbar>
|
||||
|
||||
|
||||
<ion-content #content padding>
|
||||
|
||||
<h3>Page 3</h3>
|
||||
|
||||
<p>
|
||||
<button menu-toggle>Toggle Menu</button>
|
||||
</p>
|
||||
|
||||
<f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f>
|
||||
|
||||
</ion-content>
|
||||
@@ -7,6 +7,9 @@ import {NavParams, NavController} from 'ionic/ionic';
|
||||
template: '' +
|
||||
'<ion-navbar *navbar primary>' +
|
||||
'<ion-title>{{title}}</ion-title>' +
|
||||
'<ion-nav-items primary>' +
|
||||
'<button><icon star></icon></button>' +
|
||||
'</ion-nav-items>' +
|
||||
'<ion-nav-items secondary>' +
|
||||
'<button>S1</button>' +
|
||||
'</ion-nav-items>' +
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
|
||||
<ion-navbar *navbar primary>
|
||||
<ion-navbar *navbar>
|
||||
<a menu-toggle>
|
||||
<icon menu></icon>
|
||||
</a>
|
||||
<ion-title>First View</ion-title>
|
||||
</ion-navbar>
|
||||
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
|
||||
<ion-navbar *navbar primary>
|
||||
<ion-title>Second View</ion-title>
|
||||
<ion-nav-items secondary>
|
||||
<button>
|
||||
<icon help></icon>
|
||||
</button>
|
||||
</ion-nav-item>
|
||||
</ion-navbar>
|
||||
|
||||
<ion-content class="padding">
|
||||
|
||||
@@ -226,6 +226,10 @@ export class ViewItem {
|
||||
return (this.viewCtrl ? this.viewCtrl.indexOf(this) : -1);
|
||||
}
|
||||
|
||||
isRoot() {
|
||||
return this.index === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user