Ionic 4 Bugs LoadingController, AlertController, ToastController

#1

Hello guys!

I’m having trouble using the LoadingController, ToastController and AlerControler on Ionic 4

import { Platform, NavController, NavParams, AlertController,
  LoadingController, ToastController } from '@ionic/angular';

@Injectable({
     providedIn: 'root'
})
export class BaseService {

constructor(public loadingCtrl: LoadingController, public alertCntrl: AlertController,
    public toast: ToastController, public platform: Platform) {

  }

Ionic info

Could anyone help me with this issue?
Thanks in advance!

#2

In Ionic 4 the API changed for most presentable interfaces. Check out the beta docs for more details but here is how you create the alert/load/toast in Ionic 4:


They use async functions now keep the code functioning if the render takes a while.

1 Like
#3

It worked. Thanks a lot for the help! :smile:

#4

Awesome to hear! Just be careful with async functions as they can get tricky when you add more code to them then just the presented interface but if you use a factory to control the alerts you should be fine.

#5

Thanks so much! This was driving me nuts, got it working now :slight_smile: