diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 238bde8ac00e74889422cc7050b28aac01c7b98b..acf47d2da3b7015b57ceefaab4f209c4357c84d8 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -15,6 +15,7 @@ import { IonicStorageModule } from '@ionic/storage'; import { AppComponent } from './app.component'; import { AppRoutingModule } from './app-routing.module'; import { RestService } from './rest.service'; +import { ToastService } from './services/toast.service'; @NgModule({ declarations: [AppComponent], @@ -31,6 +32,7 @@ import { RestService } from './rest.service'; StatusBar, SplashScreen, RestService, + ToastService, { provide: RouteReuseStrategy, useClass: IonicRouteStrategy } ], bootstrap: [AppComponent] diff --git a/src/app/services/toast.service.spec.ts b/src/app/services/toast.service.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..2dc86ddfe0e0d86894155ddd7aabf2e8f5a46378 --- /dev/null +++ b/src/app/services/toast.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { ToastService } from './toast.service'; + +describe('ToastService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: ToastService = TestBed.get(ToastService); + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/services/toast.service.ts b/src/app/services/toast.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..e892ad39c5c205b82f37b7c796395ae34f98e0ab --- /dev/null +++ b/src/app/services/toast.service.ts @@ -0,0 +1,24 @@ +import { Injectable } from '@angular/core'; +import { ToastController } from '@ionic/angular'; + +@Injectable({ + providedIn: 'root' +}) +export class ToastService { + + toast: any; + + constructor(public toastController: ToastController) { } + + showToast(message) { + this.toast = this.toastController.create({ + message: message, + duration: 2000 + }).then((toastData)=>{ + toastData.present(); + }); + } + HideToast(){ + this.toast = this.toastController.dismiss(); + } +}