Commit 59cc3ed6 authored by Ratnadeep Rajendra Kharade's avatar Ratnadeep Rajendra Kharade
Browse files

Added service to show toast message.

parent 6fe5f51f
......@@ -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]
......
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();
});
});
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();
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment