오늘만살자
알람 - All 본문
- src/pages/other/other.html
<!--
Generated template for the OtherPage page.
See http://ionicframework.com/docs/components/#navigation for more info on
Ionic pages and navigation.
-->
<ion-header>
<ion-navbar>
<button ion-button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>other</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding class="action-sheet-button-page">
<button ion-button block color="dark" (click)="showAlert()">Show Basic Alert</button>
<button ion-button block color="secondary" (click)="showPrompt()">Show Prompt Alert</button>
<button ion-button color="primary" block (click)="showConfirm()">Show Confirm Alert</button>
<button ion-button block color="primary" (click)="showRadio()">Show Radio Alert</button>
<button ion-button block color="danger" (click)="showCheckbox()">Show Checkbox Alert</button>
</ion-content>
- src/pages/other/other.ts
import { Component } from '@angular/core';
import {AlertController, NavController, NavParams} from 'ionic-angular';
/**
* Generated class for the OtherPage page.
*
* See http://ionicframework.com/docs/components/#navigation for more info
* on Ionic pages and navigation.
*/
@Component({
selector: 'page-other',
templateUrl: 'other.html',
})
export class OtherPage {
constructor(public navCtrl: NavController, public navParams: NavParams, public alertCtrl: AlertController) {
}
showAlert() {
let alert = this.alertCtrl.create({
title: 'New Friend!',
message: 'Your friend, Obi wan Kenobi, just approved your friend request!',
buttons: ['Ok']
});
alert.present()
}
showPrompt(){
let prompt = this.alertCtrl.create({
title: 'Login',
message: "Enter a name for this new album you're so keen on adding",
inputs: [
{
name: 'title',
placeholder: 'Title'
},
],
buttons: [
{
text: 'Cancel',
handler: data => {
console.log('Cancel clicked');
}
},
{
text: 'Save',
handler: data => {
console.log('Saved clicked');
}
}
]
});
prompt.present();
}
showConfirm(){
let confirm = this.alertCtrl.create({
title: 'Use this lightsaber?',
message: 'Do you agree to use this lightsaber to do good across the intergalactic galaxy?',
buttons: [
{
text: 'Disagree',
handler: () => {
console.log('Disagree clicked');
}
},
{
text: 'Agree',
handler: () => {
console.log('Agree clicked');
}
}
]
});
confirm.present()
}
testRadioOpen: boolean;
testRadioResult;
showRadio(){
let alert = this.alertCtrl.create();
alert.setTitle('Lightsaber color');
alert.addInput({
type: 'radio',
label: 'Blue',
value: 'blue',
checked: true
});
alert.addInput({
type: 'radio',
label: 'Green',
value: 'green'
});
alert.addInput({
type: 'radio',
label: 'Red',
value: 'red'
});
alert.addInput({
type: 'radio',
label: 'Yellow',
value: 'yellow'
});
alert.addInput({
type: 'radio',
label: 'Purple',
value: 'purple'
});
alert.addInput({
type: 'radio',
label: 'White',
value: 'white'
});
alert.addInput({
type: 'radio',
label: 'Black',
value: 'black'
});
alert.addButton('Cancel');
alert.addButton({
text: 'OK',
handler: data => {
this.testRadioOpen = false;
this.testRadioResult = data;
}
});
alert.present();
}
testCheckboxOpen: boolean;
testCheckboxResult;
showCheckbox(){
let alert = this.alertCtrl.create();
alert.setTitle('Which planets have you visited?');
alert.addInput({
type: 'checkbox',
label: 'Alderaan',
value: 'value1',
checked: true
});
alert.addInput({
type: 'checkbox',
label: 'Bespin',
value: 'value2'
});
alert.addInput({
type: 'checkbox',
label: 'Coruscant',
value: 'value3'
});
alert.addInput({
type: 'checkbox',
label: 'Endor',
value: 'value4'
});
alert.addInput({
type: 'checkbox',
label: 'Hoth',
value: 'value5'
});
alert.addInput({
type: 'checkbox',
label: 'Jakku',
value: 'value6'
});
alert.addInput({
type: 'checkbox',
label: 'Naboo',
value: 'value6'
});
alert.addInput({
type: 'checkbox',
label: 'Takodana',
value: 'value6'
});
alert.addInput({
type: 'checkbox',
label: 'Tatooine',
value: 'value6'
});
alert.addButton('Cancel');
alert.addButton({
text: 'Okay',
handler: data => {
console.log('Checkbox data:', data);
this.testCheckboxOpen = false;
this.testCheckboxResult = data;
}
});
alert.present().then(() => {
this.testCheckboxOpen = true;
});
}
ionViewDidLoad() {
console.log('ionViewDidLoad OtherPage');
}
}
위 처럼 변경하면.
basic alerts
prompt alerts
confirmation alerts
radio alerts
checkbox alerts
을 실행할 수 있다.
'ionic' 카테고리의 다른 글
빌드하기 (0) | 2017.07.20 |
---|---|
리스트에서 화살표가 안보일때 (0) | 2017.07.19 |
알람 - Basic Alerts (0) | 2017.07.18 |
페이지 추가 (0) | 2017.07.18 |
ionic2 설치 실행 (0) | 2017.07.18 |
Comments