Within my app.component.ts file, I have the following code snippet:
export class AppComponent implements OnInit {
constructor(private auth: AuthService, private fireBaseService: FirebaseService, ) {}
ngOnInit() {
this.auth.run();
document.addEventListener('deviceready', this.fireBaseService.onDeviceReady, false);
}
In the Firebase service, my simplified code (in reality I intend to do more than console.log()) looks like this:
export class FirebaseService {
output = '';
private audioObj = new Audio();
constructor() {
console.log('initialized firebaseservice');
}
test() {
console.log('test');
}
onDeviceReady() {
this.test();
}
}
When running the application, the console outputs:
initialized firebaesservice
this.test is not a function.
What is the best way to call the test() method from within onDeviceReady() in the firebaseservice?