docs(demos): update alert demo

This commit is contained in:
Drew Rygh
2016-01-05 14:55:37 -06:00
parent b083ac2c47
commit 40e5bdbfd0
5 changed files with 56 additions and 54 deletions

View 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();
// }
// }
}

View File

@ -5,6 +5,6 @@
<ion-content padding> <ion-content padding>
<button dark (click)="doAlert()">Alert</button> <button dark (click)="doAlert()">Alert</button>
<button light (click)="doPrompt()">Prompt</button> <!-- <button light (click)="doPrompt()">Prompt</button>
<button primary (click)="doConfirm()">Confirm</button> <button primary (click)="doConfirm()">Confirm</button> -->
</ion-content> </ion-content>

View File

@ -13,7 +13,7 @@ import * as lists from './lists/lists';
import * as menus from './menus/menus'; import * as menus from './menus/menus';
import * as modals from './modals/modals'; import * as modals from './modals/modals';
import * as navigation from './navigation/navigation'; 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 slides from './slides/slides';
import * as tabs from './tabs/tabs'; import * as tabs from './tabs/tabs';
@ -72,6 +72,8 @@ export function getPageFor(hash) {
return { return {
'overview': actionSheets.BasicPage, 'overview': actionSheets.BasicPage,
'action-sheets': actionSheets.BasicPage, 'action-sheets': actionSheets.BasicPage,
'alert': alerts.BasicPage,
'badges': badges.BasicPage, 'badges': badges.BasicPage,
'buttons': buttons.BasicPage, 'buttons': buttons.BasicPage,
@ -127,7 +129,6 @@ export function getPageFor(hash) {
'menus': menus.BasicPage, 'menus': menus.BasicPage,
'modals': modals.BasicPage, 'modals': modals.BasicPage,
'navigation': navigation.BasicPage, 'navigation': navigation.BasicPage,
'popups': popups.BasicPage,
'slides': slides.BasicPage, 'slides': slides.BasicPage,
'tabs': tabs.BasicPage, 'tabs': tabs.BasicPage,

View File

@ -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();
}
}
}