Hello,
In Ionic I am trying to use Platform.ready() but I am getting the following error:
ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'then' of undefined
TypeError: Cannot read property 'then' of undefined
at TeamComponent.<anonymous> (team.component.ts:25)
at step (tslib.es6.js:97)
at Object.next (tslib.es6.js:78)
at tslib.es6.js:71
at new ZoneAwarePromise (zone.js:910)
at Module.__awaiter (tslib.es6.js:67)
at team.component.ts:24
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:391)
at Object.onInvoke (core.js:17298)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:390)
at resolvePromise (zone.js:831)
at resolvePromise (zone.js:788)
at zone.js:892
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
at Object.onInvokeTask (core.js:17289)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
at drainMicroTaskQueue (zone.js:601)
at ZoneTask.push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:502)
at invokeTask (zone.js:1744)
import { Component, OnInit } from '@angular/core';
import { EmailComposer } from '@ionic-native/email-composer/ngx';
import { NavController, Platform, ToastController } from '@ionic/angular';
@Component({
selector: 'team',
templateUrl: './team.component.html',
styleUrls: ['./team.component.scss'],
})
export class TeamComponent implements OnInit {
constructor(
private email: EmailComposer,
private nav: NavController,
private platform: Platform,
private toast: ToastController
) { }
ngOnInit() {}
public openEmailApp(email: string) {
this.platform.ready().then(() => {
this.email.isAvailable().then(async (available: boolean) =>{
if (available) {
this.email.open({
to: email
});
} else {
let toast: any = await this.toast.create();
await toast.present();
}
});
});
}
However, if I do a console log like this, it works and gives me ‘dom’ string: console.log(await this.platform.ready())
Whats the issue?
Thanks