docs(demos): add id API demo

references driftyco/ionic-site#397
This commit is contained in:
Brandy Carney
2016-02-04 14:25:51 -05:00
parent cf759261ac
commit 856002ef0c
4 changed files with 88 additions and 0 deletions

29
demos/id/index.ts Normal file
View 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
View 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
View 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>

View File

@@ -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]'