本文整理匯總了TypeScript中ionic-angular.AlertController.create方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript AlertController.create方法的具體用法?TypeScript AlertController.create怎麽用?TypeScript AlertController.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ionic-angular.AlertController
的用法示例。
在下文中一共展示了AlertController.create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: confirm
/**
* Opens a modal to ask if the user is sure of something
* @param question The delete question
* @param on_confirmed The on confirmed callback
* @param on_cancel The on cancel callback
*/
public confirm(question: string, on_confirmed: Function, on_cancel?: Function): void {
let alert = this.alert_controller.create({
title: 'Warning',
message: question,
buttons: [
{
text: 'Continue',
handler: typeof (on_confirmed) === 'function' ? on_confirmed : () => { }
},
{
text: 'Cancel',
role: 'cancel',
handler: typeof (on_cancel) === 'function' ? on_cancel : () => { }
}
]
} as AlertOptions);
alert.present();
}
示例2: onTempOrdersCanceled
onTempOrdersCanceled() {
// if there are open temp orders -> ask user
if (this.orderService.getTempOrdersByArea(this.area).length > 0) {
let confirm = this.alertController.create({
title: this.translationService.getTranslation('ATTENTION'),
message: this.translationService.getTranslation('OPEN_TEMP_ORDERS_WARNING'),
buttons: [
{ text: this.translationService.getTranslation('YES'),
handler: () => { this.nav.popToRoot(); }
},
{ text: this.translationService.getTranslation('NO') }
]
});
confirm.present();
} else {
this.nav.popToRoot();
}
}
示例3: takeMeHome
takeMeHome():void{
if( !this.latitude ||!this.longitude){
let alert = this.alertCtrl.create({
title : 'Nowhere to go!',
subTitle : 'You need to set your camp location first.For now, want to launch Maps to find your own way home?',
buttons:['Ok']
});
alert.present();
}else{
let destination = this.latitude+','+this.longitude;
if( this.platform.is('ios')){
window.open('maps://?q='+destination+"_system");
}else{
let label = encodeURI('My Campsite');
window.open("geo:0,0?q="+destination+"("+label+")","_system");
}
}
}
示例4: constraintTask
public constraintTask(task: any): void {
let alert: any = this.alertCtrl.create();
alert.setTitle('Task Constrained?');
alert.addInput({ type: 'checkbox', label: 'Constraint Check OK',
value: true, checked: task.constraints});
alert.addButton('Cancel');
alert.addButton({
text : 'Save',
handler: data => {
if (data[0] === true) {
this.task.constraints = true;
} else {
this.task.constraints = false;
}
this.taskService.updateD();
},
});
alert.present();
}
示例5: doCleanCache
doCleanCache() {
let confirm = this.alertCtrl.create({
title: this.translate.instant('CACHE_CLEAR'),
message: this.translate.instant('CACHE_CLEAR_PROMPT'),
buttons: [
{
text: this.translate.instant('CANCEL')
},
{
text: this.translate.instant('OK'),
handler: () => {
this.store.dispatch(cleanCache());
this.toast.show(this.translate.instant('CACHE_CLEARED'));
}
}
]
});
confirm.present();
}
示例6:
this.translate.get(['app.message.' + level + '.title', 'app.action.yes', 'app.action.no']).subscribe(message => {
let title = message['app.message.' + level + '.title'];
let yes = message['app.action.yes'];
let no = message['app.action.no'];
let alert = this.alertCtrl.create({
title: title,
subTitle: content,
buttons: [{
text: yes,
handler: okHandler
},
{
text: no,
handler: noHandler
}]
});
alert.present();
});
示例7: expeditionMenu
expeditionMenu()
{
let alert = this.alerCtrl.create();
alert.setTitle('Expedition');
alert.addInput({
type: 'radio',
label: 'Expedition 1 | dur: 10',
value: '1',
checked: false
});
alert.addInput({
type: 'radio',
label: 'Expedition 2 | dur: 30',
value: '2',
checked: false
});
alert.addInput({
type: 'radio',
label: 'Expedition 3 | dur: 50',
value: '3',
checked: false
});
alert.addInput({
type: 'radio',
label: 'Expedition 4 | dur: 70',
value: '4',
checked: false
});
alert.addButton('Cancel');
alert.addButton({
text: 'Ok',
handler: data => {
console.log('Radio data:', data);
this.testRadioOpen = false;
this.testRadioResult = data;
}
});
alert.present().then(() => {
this.testRadioOpen = true;
});
}
示例8: onClick
/**
* Called when a HTML element with 'clear-history' directive is clicked. <br/>
* It opens an dialog which allows the user to clear his navigation history or cancel the operation.
* @return {void}
*/
@HostListener('click', ['$event.target'])
public onClick(): void {
Analytics.trackEvent('Clear History', 'click', 'button');
let confirm: Alert = this.ctrl.create({
title: this.Text.COMPONENT_CLEAR_HISTORY_ALERT_TITLE,
message: this.Text.COMPONENT_CLEAR_HISTORY_ALERT_MESSAGE,
buttons: [
{
text: this.Text.COMPONENT_CLEAR_HISTORY_ALERT_BUTTON_NO,
handler: (): void => console.log('Clear canceled'),
},
{
text: this.Text.COMPONENT_CLEAR_HISTORY_ALERT_BUTTON_YES,
handler: (): void => this.clearHistory(),
},
],
});
confirm.present(confirm);
}
示例9: setTimeout
setTimeout(() => {
if (Network.connection == Connection.NONE) {
console.log("You need internet connection to be able to run this application, please connect to internet and try again.");
let alert = this.alertController.create({
title: 'Opps!',
subTitle: "You need internet connection to be able to run this application, please connect to internet and try again.",
buttons: [{
text: 'OK',
role: 'cancel',
handler: () => {
this.navController.setRoot(NoInternetPage);
}
}]
});
alert.present(alert);
// this.platform.exitApp();
}
}, 1000);
示例10: createReminder
createReminder() {
if (this.gameForm.invalid) {
const alert = this.alertCtrl.create({
title: 'Invalid Input',
subTitle: 'You have to set game info to create reminder.',
buttons: ['OK']
});
alert.present();
} else {
const values = this.gameForm.value;
let gameInfo: any = {};
gameInfo.player = this.report.player.name;
gameInfo.opponent = values.opponent;
gameInfo.competition = values.competition;
gameInfo.date = moment(values.date + ' ' + values.time, 'DD.MM.YYYY. HH:mm');
console.log(gameInfo);
this.addEvent(gameInfo);
}
}
示例11:
this.translateService.get(['areYouSure', 'resetListInfo', 'accept', 'cancel'], {}).subscribe((texts) => {
let confirm = this.alertCtrl.create({
title: texts['areYouSure'],
message: texts['resetListInfo'],
buttons: [
{
text: texts['cancel'],
handler: () => {
}
},
{
text: texts['accept'],
handler: () => {
this.resetDB();
}
}
]
});
confirm.present();
});
示例12:
this.storage.get("user").then((res) => {
if (res.user) {
this.navCtrl.push(NodeCommentPage, {
userId: res.user._id,
toUser:toUser,
note:this.note,
}
);
} else {
let alert = this.alertCtrl.create({
title: 'error',
subTitle: 'auth error ,please relogin!',
buttons: ['OK'],
});
alert.present();
}
}).catch((error: Error) => {
示例13: presentAlert
presentAlert() {
const alert = this.alertCtrl.create({
title: 'Smart Stock Update',
subTitle: 'You are running low on an item',
buttons: [{text:'Update My List',
handler: () => {
console.log("placeholder")
// this.restService.updateSSQuantity().then(res =>{
// console.log(res);
// })
}},
{text:'Restock on Amazon',
handler: () => {
window.open("https://www.amazon.com/gp/cart/aws-merge.html?cart-id=133-8971498-2032938&associate-id=123402bb-20&hmac=uztkD9ycMp52gsM%2FIqAIFA9rscQ%3D&SubscriptionId=AKIAJONRAXIF4HTX73DQ&MergeCart=False",'_system', 'location=yes');
}},
'Don\'t Update']
});
alert.present();
}
示例14: themeAlert
themeAlert() {
let alert = this.alertCtrl.create();
alert.setSubTitle('Choose A Theme');
for (let theme in PREFERENCES.THEME) {
alert.addInput({
type: 'radio',
label: `${PREFERENCES.THEME[theme]}`,
value: PREFERENCES.THEME[theme],
checked: this.themeVal === PREFERENCES.THEME[theme] ? true: false
});
}
alert.addButton('Cancel');
alert.addButton({
text: 'OK',
handler: data => {
this.store.dispatch(new PrefActions.ChangeTheme(data));
}
});
alert.present();
}
示例15: search
private search(): void {
let prompt = this.alertCtrl.create({
title: 'Search',
message: "Enter a genre, artist or anything!",
inputs: [
{
name: 'term',
placeholder: 'Tame Impala'
},
],
buttons: [
{
text: 'Cancel',
handler: data => {
console.log('Cancel clicked');
}
},
{
text: 'search',
handler: data => {
console.log('Saved clicked');
let loading = this.loadCtrl.create({
content: "Getting songs..."
});
loading.present().then(() => {
this.musicService.getFirstTracks(data.term).then((tracks) => {
this.songs = tracks;
loading.dismiss();
});
});
}
}
]
});
prompt.present();
}