I would like to create a static method in a public class with a ToastController
so that I can access this method across multiple classes. I tried to do it this way but it did not work:
export class Utils {
constructor(public toastCtrl: ToastController) {
}
static showToast(message, pos) {
let toast = this.toastCtrl.create({ /* <---- erro nessa linha */
message: message,
duration: 3000,
position: pos
});
toast.onDidDismiss(() => {
console.log('Dismissed toast');
});
toast.present();
}
}
Basically the purpose reuse code. How can I create a static method in a public class?