mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
59
ionic/components/alert/test/dismiss/index.ts
Normal file
59
ionic/components/alert/test/dismiss/index.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { Alert, NavController, App, Page } from 'ionic-angular/index';
|
||||
|
||||
|
||||
@Page({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
export class E2EPage {
|
||||
|
||||
constructor(private nav: NavController) {}
|
||||
|
||||
submit() {
|
||||
var alert = Alert.create({
|
||||
title: 'Not logged in',
|
||||
message: 'Sign in to continue.',
|
||||
buttons: [
|
||||
{
|
||||
text: 'Cancel',
|
||||
role: 'cancel'
|
||||
},
|
||||
{
|
||||
text: 'Sign in',
|
||||
handler: () => {
|
||||
console.log('Sign in');
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
alert.onDismiss((asdf) => {
|
||||
console.log('dismiss');
|
||||
this.nav.push(AnotherPage);
|
||||
});
|
||||
|
||||
this.nav.present(alert);
|
||||
}
|
||||
}
|
||||
|
||||
@Page({
|
||||
template: `
|
||||
<ion-navbar *navbar>
|
||||
<ion-title>Another Page</ion-title>
|
||||
</ion-navbar>
|
||||
<ion-content padding>
|
||||
Welcome!
|
||||
</ion-content>
|
||||
`
|
||||
})
|
||||
class AnotherPage {}
|
||||
|
||||
|
||||
@App({
|
||||
template: '<ion-nav [root]="root"></ion-nav>'
|
||||
})
|
||||
class E2EApp {
|
||||
root;
|
||||
constructor() {
|
||||
this.root = E2EPage;
|
||||
}
|
||||
}
|
||||
22
ionic/components/alert/test/dismiss/main.html
Normal file
22
ionic/components/alert/test/dismiss/main.html
Normal file
@@ -0,0 +1,22 @@
|
||||
<ion-navbar *navbar>
|
||||
<ion-title>
|
||||
Alert Dismiss
|
||||
</ion-title>
|
||||
</ion-navbar>
|
||||
|
||||
<ion-content>
|
||||
|
||||
<ion-list>
|
||||
<ion-item>
|
||||
<ion-label floating>Input text here</ion-label>
|
||||
<ion-input type="text"></ion-input>
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
|
||||
<div padding>
|
||||
<button primary block (click)="submit()">
|
||||
Submit
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</ion-content>
|
||||
@@ -108,8 +108,10 @@ export class ViewController {
|
||||
}
|
||||
|
||||
dismiss(data?: any, role?: any) {
|
||||
this._onDismiss && this._onDismiss(data, role);
|
||||
return this._nav.remove(this._nav.indexOf(this), 1, this._leavingOpts);
|
||||
return this._nav.remove(this._nav.indexOf(this), 1, this._leavingOpts).then(() => {
|
||||
this._onDismiss && this._onDismiss(data, role);
|
||||
return data;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user