Created
January 9, 2018 09:54
-
-
Save jayserdny/22e409d29523cdb09ca98275fb9312da to your computer and use it in GitHub Desktop.
Alerts.ts for steemit tutorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { AlertController, ToastController } from 'ionic-angular'; | |
@Injectable() | |
export class AlertsProvider { | |
constructor(private alertCtrl: AlertController, public toastCtrl: ToastController) {} | |
/** | |
* Method to present alert with error or message | |
* | |
* @param {any} msg: alert | |
*/ | |
public showAlert(msg): void { | |
const alert = this.alertCtrl.create({ | |
buttons: ['OK'], | |
message: msg || msg.message, | |
title: 'Oops!' | |
}); | |
alert.present(); | |
} | |
/** | |
* Method to present toast with error or message | |
* | |
* @param {any} msg: alert | |
*/ | |
public presentToast(msg: any): void { | |
let toast = this.toastCtrl.create({ | |
message: msg, | |
duration: 4000 | |
}); | |
toast.present(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment