diff --git a/ionic/components/menu/menu-toggle.ts b/ionic/components/menu/menu-toggle.ts index 0213cb4306..ce2000455f 100644 --- a/ionic/components/menu/menu-toggle.ts +++ b/ionic/components/menu/menu-toggle.ts @@ -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; + } + } diff --git a/ionic/components/menu/test/basic/index.ts b/ionic/components/menu/test/basic/index.ts index 9229b217de..698cec4a47 100644 --- a/ionic/components/menu/test/basic/index.ts +++ b/ionic/components/menu/test/basic/index.ts @@ -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 }, ]; } diff --git a/ionic/components/menu/test/basic/page2.html b/ionic/components/menu/test/basic/page2.html index 4a7e564244..ab2e7ad7b3 100644 --- a/ionic/components/menu/test/basic/page2.html +++ b/ionic/components/menu/test/basic/page2.html @@ -19,4 +19,8 @@

+

+ +

+ diff --git a/ionic/components/menu/test/basic/page3.html b/ionic/components/menu/test/basic/page3.html new file mode 100644 index 0000000000..a2d65e2ad5 --- /dev/null +++ b/ionic/components/menu/test/basic/page3.html @@ -0,0 +1,25 @@ + + + + + + + + + Menu + + + + + + + +

Page 3

+ +

+ +

+ + + +
diff --git a/ionic/components/nav/test/basic/index.ts b/ionic/components/nav/test/basic/index.ts index c525b27b28..196198ba88 100644 --- a/ionic/components/nav/test/basic/index.ts +++ b/ionic/components/nav/test/basic/index.ts @@ -7,6 +7,9 @@ import {NavParams, NavController} from 'ionic/ionic'; template: '' + '' + '{{title}}' + + '' + + '' + + '' + '' + '' + '' + diff --git a/ionic/components/nav/test/routing/view1.html b/ionic/components/nav/test/routing/view1.html index 449c1db122..b1f74fd928 100644 --- a/ionic/components/nav/test/routing/view1.html +++ b/ionic/components/nav/test/routing/view1.html @@ -1,5 +1,8 @@ - + + + + First View diff --git a/ionic/components/nav/test/routing/view2.html b/ionic/components/nav/test/routing/view2.html index 9838895cab..f7cdad7add 100644 --- a/ionic/components/nav/test/routing/view2.html +++ b/ionic/components/nav/test/routing/view2.html @@ -1,6 +1,11 @@ Second View + + + diff --git a/ionic/components/view/view-item.ts b/ionic/components/view/view-item.ts index 7b3501ae73..b0c18fec83 100644 --- a/ionic/components/view/view-item.ts +++ b/ionic/components/view/view-item.ts @@ -226,6 +226,10 @@ export class ViewItem { return (this.viewCtrl ? this.viewCtrl.indexOf(this) : -1); } + isRoot() { + return this.index === 0; + } + /** * TODO */