demos(actionSheet): update actionsheet

This commit is contained in:
Adam Bradley
2015-12-31 20:15:58 -06:00
parent e0b0d7ac30
commit 5c43f7bc35
3 changed files with 32 additions and 34 deletions

View File

@ -1,2 +1 @@
<ion-nav id="nav" [root]="rootPage" #content></ion-nav> <ion-nav [root]="rootPage"></ion-nav>
<ion-overlay></ion-overlay>

View File

@ -1,51 +1,50 @@
import {App, Page, IonicApp, Config, Platform} from 'ionic/ionic'; import {App, Page, ActionSheet, NavController} from 'ionic/ionic';
import {ActionSheet} from 'ionic/ionic';
@App({ @App({
templateUrl: 'app.html' templateUrl: 'app.html'
}) })
class ApiDemoApp { class ApiDemoApp {
constructor() { constructor() {
this.rootPage = InitialPage; this.rootPage = InitialPage;
} }
} }
@Page({ @Page({
templateUrl: 'main.html' templateUrl: 'main.html'
}) })
export class InitialPage { export class InitialPage {
constructor(actionSheet: ActionSheet, platform: Platform) { constructor(nav: NavController) {
this.actionSheet = actionSheet; this.nav = nav;
this.platform = platform;
} }
open() { present() {
let actionSheet = ActionSheet.create({
this.actionSheet.open({
buttons: [ buttons: [
{ text: 'Share'}, {
{ text: 'Play'}, text: 'Destructive',
{ text: 'Favorite'} style: 'destructive',
], handler: () => {
destructiveText: 'Delete', console.log('Destructive clicked');
titleText: 'Albums', }
cancelText: 'Cancel', },
cancel: () => { {
console.log('Canceled'); text: 'Archive',
}, handler: () => {
destructiveButtonClicked: () => { console.log('Archive clicked');
console.log('Destructive clicked'); }
}, },
buttonClicked: (index) => { {
console.log('Button clicked', index); text: 'Cancel',
if (index == 1) { return false; } style: 'cancel',
return true; handler: () => {
} console.log('Cancel clicked');
}
}).then(actionSheetRef => { }
this.actionSheetRef = actionSheetRef; ]
}); });
this.nav.present(actionSheet);
} }
} }

View File

@ -4,6 +4,6 @@
<ion-content padding> <ion-content padding>
<ion-row> <ion-row>
<button full block (click)="open()">Open Action Sheet</button> <button full block (click)="present()">Open Action Sheet</button>
</ion-row> </ion-row>
<ion-content> <ion-content>