5
I would like to create a static method in a public class with a ToastController
so that I can access this method in several classes. I tried to do this way below but it didn’t 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 to reuse code. How can I create a static method in a public class?
Thanks worked for me!!!!!!! https://github.com/cleidimarviana/SOpt/blob/master/TypeScript/utils.ts
– williamSM
Do not add "thank you" as an answer. When reputation points sufficient, you will be able vote in favour of questions and answers which it considers useful. - Of Revision
– Homer Simpson