mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 21:48:42 +08:00
docs(demos): update alert demo
This commit is contained in:
51
demos/component-docs/alerts/basic/pages.ts
Normal file
51
demos/component-docs/alerts/basic/pages.ts
Normal file
@ -0,0 +1,51 @@
|
||||
import {Page, Alert, NavController} from 'ionic/ionic';
|
||||
import {AndroidAttribute} from '../../helpers';
|
||||
import {forwardRef} from 'angular2/core';
|
||||
|
||||
|
||||
@Page({
|
||||
templateUrl: 'alerts/basic/template.html',
|
||||
directives: [forwardRef(() => AndroidAttribute)]
|
||||
})
|
||||
export class BasicPage {
|
||||
|
||||
constructor(nav: NavController) {
|
||||
this.nav = nav;
|
||||
}
|
||||
|
||||
doAlert() {
|
||||
let alert = Alert.create({
|
||||
title: "New Friend!",
|
||||
subTitle: "Your friend, Obi wan Kenobi, just accepted your friend request!",
|
||||
buttons: ['Ok']
|
||||
});
|
||||
this.nav.present(alert);
|
||||
}
|
||||
|
||||
// doPrompt() {
|
||||
// this.popup.prompt({
|
||||
// title: "New Album",
|
||||
// template: "Enter a name for this new album you're so keen on adding",
|
||||
// inputPlaceholder: "Title",
|
||||
// okText: "Save"
|
||||
// });
|
||||
// }
|
||||
|
||||
// doConfirm() {
|
||||
// this.popup.confirm({
|
||||
// title: "Use this lightsaber?",
|
||||
// template: "Do you agree to use this lightsaber to do good across the intergalactic galaxy?",
|
||||
// cancelText: "Disagree",
|
||||
// okText: "Agree"
|
||||
// });
|
||||
// }
|
||||
|
||||
// onPageWillLeave() {
|
||||
// let popup = this.popup.get();
|
||||
// // only try to close if there is an active popup
|
||||
// if (popup) {
|
||||
// popup.close();
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
@ -5,6 +5,6 @@
|
||||
|
||||
<ion-content padding>
|
||||
<button dark (click)="doAlert()">Alert</button>
|
||||
<button light (click)="doPrompt()">Prompt</button>
|
||||
<button primary (click)="doConfirm()">Confirm</button>
|
||||
<!-- <button light (click)="doPrompt()">Prompt</button>
|
||||
<button primary (click)="doConfirm()">Confirm</button> -->
|
||||
</ion-content>
|
@ -13,7 +13,7 @@ import * as lists from './lists/lists';
|
||||
import * as menus from './menus/menus';
|
||||
import * as modals from './modals/modals';
|
||||
import * as navigation from './navigation/navigation';
|
||||
import * as popups from './popups/popups';
|
||||
import * as alerts from './alerts/alerts';
|
||||
import * as slides from './slides/slides';
|
||||
import * as tabs from './tabs/tabs';
|
||||
|
||||
@ -72,6 +72,8 @@ export function getPageFor(hash) {
|
||||
return {
|
||||
'overview': actionSheets.BasicPage,
|
||||
'action-sheets': actionSheets.BasicPage,
|
||||
'alert': alerts.BasicPage,
|
||||
|
||||
'badges': badges.BasicPage,
|
||||
|
||||
'buttons': buttons.BasicPage,
|
||||
@ -127,7 +129,6 @@ export function getPageFor(hash) {
|
||||
'menus': menus.BasicPage,
|
||||
'modals': modals.BasicPage,
|
||||
'navigation': navigation.BasicPage,
|
||||
'popups': popups.BasicPage,
|
||||
'slides': slides.BasicPage,
|
||||
|
||||
'tabs': tabs.BasicPage,
|
||||
|
@ -1,50 +0,0 @@
|
||||
import {Page, Popup} from 'ionic/ionic';
|
||||
import {AndroidAttribute} from '../../helpers';
|
||||
import {forwardRef} from 'angular2/core';
|
||||
|
||||
|
||||
@Page({
|
||||
templateUrl: 'popups/basic/template.html',
|
||||
directives: [forwardRef(() => AndroidAttribute)]
|
||||
})
|
||||
export class BasicPage {
|
||||
|
||||
constructor(popup: Popup) {
|
||||
this.popup = popup;
|
||||
}
|
||||
|
||||
doAlert() {
|
||||
this.popup.alert({
|
||||
title: "New Friend!",
|
||||
template: "Your friend, Obi wan Kenobi, just accepted your friend request!",
|
||||
cssClass: 'my-alert'
|
||||
});
|
||||
}
|
||||
|
||||
doPrompt() {
|
||||
this.popup.prompt({
|
||||
title: "New Album",
|
||||
template: "Enter a name for this new album you're so keen on adding",
|
||||
inputPlaceholder: "Title",
|
||||
okText: "Save"
|
||||
});
|
||||
}
|
||||
|
||||
doConfirm() {
|
||||
this.popup.confirm({
|
||||
title: "Use this lightsaber?",
|
||||
template: "Do you agree to use this lightsaber to do good across the intergalactic galaxy?",
|
||||
cancelText: "Disagree",
|
||||
okText: "Agree"
|
||||
});
|
||||
}
|
||||
|
||||
onPageWillLeave() {
|
||||
let popup = this.popup.get();
|
||||
// only try to close if there is an active popup
|
||||
if (popup) {
|
||||
popup.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user