Added a toast service error to show error messages on the screen isntead of using console.log

This commit is contained in:
Kayaya
2020-08-21 10:44:43 +01:00
parent c046fd92c0
commit 6fdd1fb467
3 changed files with 40 additions and 3 deletions
+16
View File
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { ToastService } from './toast.service';
describe('ToastService', () => {
let service: ToastService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ToastService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
+19
View File
@@ -0,0 +1,19 @@
import { Injectable } from '@angular/core';
import { ToastController } from '@ionic/angular';
@Injectable({
providedIn: 'root'
})
export class ToastService {
constructor(public toastController: ToastController) { }
async presentToast(infoMessage: string) {
const toast = await this.toastController.create({
message: infoMessage,
duration: 2000
});
toast.present();
}
}