mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
demos(actionSheet): update actionsheet
This commit is contained in:
@ -1,2 +1 @@
|
||||
<ion-nav id="nav" [root]="rootPage" #content></ion-nav>
|
||||
<ion-overlay></ion-overlay>
|
||||
<ion-nav [root]="rootPage"></ion-nav>
|
||||
|
@ -1,51 +1,50 @@
|
||||
import {App, Page, IonicApp, Config, Platform} from 'ionic/ionic';
|
||||
import {ActionSheet} from 'ionic/ionic';
|
||||
import {App, Page, ActionSheet, NavController} from 'ionic/ionic';
|
||||
|
||||
|
||||
@App({
|
||||
templateUrl: 'app.html'
|
||||
})
|
||||
class ApiDemoApp {
|
||||
|
||||
constructor() {
|
||||
this.rootPage = InitialPage;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Page({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
export class InitialPage {
|
||||
constructor(actionSheet: ActionSheet, platform: Platform) {
|
||||
this.actionSheet = actionSheet;
|
||||
this.platform = platform;
|
||||
constructor(nav: NavController) {
|
||||
this.nav = nav;
|
||||
}
|
||||
|
||||
open() {
|
||||
|
||||
this.actionSheet.open({
|
||||
present() {
|
||||
let actionSheet = ActionSheet.create({
|
||||
buttons: [
|
||||
{ text: 'Share'},
|
||||
{ text: 'Play'},
|
||||
{ text: 'Favorite'}
|
||||
],
|
||||
destructiveText: 'Delete',
|
||||
titleText: 'Albums',
|
||||
cancelText: 'Cancel',
|
||||
cancel: () => {
|
||||
console.log('Canceled');
|
||||
},
|
||||
destructiveButtonClicked: () => {
|
||||
console.log('Destructive clicked');
|
||||
},
|
||||
buttonClicked: (index) => {
|
||||
console.log('Button clicked', index);
|
||||
if (index == 1) { return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
}).then(actionSheetRef => {
|
||||
this.actionSheetRef = actionSheetRef;
|
||||
{
|
||||
text: 'Destructive',
|
||||
style: 'destructive',
|
||||
handler: () => {
|
||||
console.log('Destructive clicked');
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Archive',
|
||||
handler: () => {
|
||||
console.log('Archive clicked');
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Cancel',
|
||||
style: 'cancel',
|
||||
handler: () => {
|
||||
console.log('Cancel clicked');
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
this.nav.present(actionSheet);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,6 @@
|
||||
|
||||
<ion-content padding>
|
||||
<ion-row>
|
||||
<button full block (click)="open()">Open Action Sheet</button>
|
||||
<button full block (click)="present()">Open Action Sheet</button>
|
||||
</ion-row>
|
||||
<ion-content>
|
||||
|
Reference in New Issue
Block a user