I am currently learning Ionic v2 and I am using document.addEventListener, but I am encountering errors as shown below:
> [11:10:21] ionic-app-scripts 0.0.47
[11:10:21] build dev started ...
[11:10:21] clean started ...
[11:10:21] clean finished in less than 1 ms
[11:10:21] copy started ...
[11:10:21] transpile started ...
[11:10:31] typescript: C:/Users/skeintech/Anguler2/sample/src/pages/sample/sample.ts, line: 25
';' expected.
L25: [11:10:31] typescript: C:/Users/skeintech/Anguler2/sample/src/pages/sample/sample.ts, line: 25 document
.addEventListener('deviceready', onDeviceReady, false);
Parameter declaration expected.
... (remaining error messages)
Here is my TypeScript code:
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Device } from 'ionic-native';
@Component({
selector: 'page-sample',
templateUrl: 'sample.html'
})
export class SamplePage {
constructor(public navCtrl: NavController) {
}
document.addEventListener('deviceready', onDeviceReady, false);
... (function definitions)
}
How can I properly format the document.addEventListener function in TypeScript for this scenario? Any help would be appreciated.