mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
29
demos/id/index.ts
Normal file
29
demos/id/index.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import {App, IonicApp, Page} from 'ionic/ionic';
|
||||
|
||||
@Page({templateUrl: 'page1.html'})
|
||||
class Page1 {
|
||||
constructor(app: IonicApp) {
|
||||
this.app = app;
|
||||
this.menu1Active();
|
||||
}
|
||||
menu1Active() {
|
||||
this.activeMenu = 'menu1';
|
||||
this.app.getComponent('menu1').enable(true);
|
||||
this.app.getComponent('menu2').enable(false);
|
||||
}
|
||||
menu2Active() {
|
||||
this.activeMenu = 'menu2';
|
||||
this.app.getComponent('menu1').enable(false);
|
||||
this.app.getComponent('menu2').enable(true);
|
||||
}
|
||||
}
|
||||
|
||||
@App({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class ApiDemoApp {
|
||||
constructor(app: IonicApp) {
|
||||
this.app = app;
|
||||
this.rootView = Page1;
|
||||
}
|
||||
}
|
||||
34
demos/id/main.html
Normal file
34
demos/id/main.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<ion-menu [content]="content" id="menu1">
|
||||
|
||||
<ion-toolbar secondary>
|
||||
<ion-title>Menu 1</ion-title>
|
||||
</ion-toolbar>
|
||||
|
||||
<ion-content>
|
||||
<ion-list>
|
||||
<button ion-item menuClose="menu1" detail-none>
|
||||
Close Menu 1
|
||||
</button>
|
||||
</ion-list>
|
||||
</ion-content>
|
||||
|
||||
</ion-menu>
|
||||
|
||||
|
||||
<ion-menu [content]="content" id="menu2">
|
||||
|
||||
<ion-toolbar danger>
|
||||
<ion-title>Menu 2</ion-title>
|
||||
</ion-toolbar>
|
||||
|
||||
<ion-content>
|
||||
<ion-list>
|
||||
<button ion-item menuClose="menu2" detail-none>
|
||||
Close Menu 2
|
||||
</button>
|
||||
</ion-list>
|
||||
</ion-content>
|
||||
|
||||
</ion-menu>
|
||||
|
||||
<ion-nav id="nav" [root]="rootView" #content swipe-back-enabled="false"></ion-nav>
|
||||
23
demos/id/page1.html
Normal file
23
demos/id/page1.html
Normal file
@@ -0,0 +1,23 @@
|
||||
<ion-navbar *navbar>
|
||||
<button [menuToggle]="activeMenu">
|
||||
<ion-icon name="menu"></ion-icon>
|
||||
</button>
|
||||
<ion-title>
|
||||
Id
|
||||
</ion-title>
|
||||
</ion-navbar>
|
||||
|
||||
|
||||
<ion-content padding>
|
||||
|
||||
<h4>Active Menu: <b primary>{{ (activeMenu == 'menu1') ? 'Menu 1' : 'Menu 2' }}</b></h4>
|
||||
|
||||
<p>This page has two menus with different id's, but only one is active at a time.</p>
|
||||
|
||||
<button block secondary (click)="menu1Active()">Make Menu 1 Active</button>
|
||||
|
||||
<button block danger (click)="menu2Active()">Make Menu 2 Active</button>
|
||||
|
||||
<button block [menuToggle]="activeMenu">Toggle Menu</button>
|
||||
|
||||
</ion-content>
|
||||
@@ -35,6 +35,8 @@ import {IonicApp} from './app';
|
||||
* *NOTE:* It is not recommended to use ID's across Pages, as there is often no
|
||||
* guarantee that the registered component has not been destroyed if its Page
|
||||
* has been navigated away from.
|
||||
*
|
||||
* @demo /docs/v2/demos/id/
|
||||
*/
|
||||
@Directive({
|
||||
selector: '[id]'
|
||||
|
||||
Reference in New Issue
Block a user