import { Injectable } from '@angular/core' ; import { AlertController , AlertOptions } from 'ionic-angular' ; @ Injectable ( ) export class DialogService { constructor ( private alert_controller ) { } param message param on_confirmed param on_cancel public confirm_delete ( question , on_confirmed , on_cancel ? ) { let alert = this . alert_controller . create ( { title : 'Warning' , message : question , buttons : [ { text : 'Delete' , handler : typeof ( on_confirmed ) === 'function' ? on_confirmed : ( ) => { } } , { text : 'Cancel' , role : 'cancel' , handler : typeof ( on_cancel ) === 'function' ? on_cancel : ( ) => { } } ] } as AlertOptions ) ; alert . present ( ) ; } param question param on_confirmed param on_cancel public confirm ( question , on_confirmed , on_cancel ? ) { 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 ( ) ; } }