cordova-plugin-screen-orientation
cordova-plugin-screen-orientation copied to clipboard
OnChange event not working
I am using this plugin and I wanted to get the event when user rotates the screen. But, I get below error.
Error
core.js:15724 ERROR TypeError: Invalid event target at setupSubscription (fromEvent.js:50) at Observable._subscribe (fromEvent.js:24) at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe (Observable.js:43) at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe (Observable.js:29) at new TestPage (test.page.ts:10) at createClass (core.js:22160) at createDirectiveInstance (core.js:22029) at createViewNodes (core.js:23255) at callViewAction (core.js:23571) at execComponentViewsAction (core.js:23490)
My code
this.screenOrientation.onChange().subscribe( () => { console.log(this.screenOrientation.type); } );
I am using this plugin in conjunction with Angular 7 & ionic 4
Thanks a lot for your issue, however the issue template exists for a reason 😉 It helps us to debug the issue further and to provide a solution much faster. With important information missing, we unfortunately can't help you.
Therefore, please edit this issue accordingly or close and create a new one and make sure to provide all the required information.
Also, this seems like an Angular/Ionic issue. Please verify that the event listening via a plain window.addEventListener works.
Thanks a lot for your issue, however the issue template exists for a reason 😉 It helps us to debug the issue further and to provide a solution much faster. With important information missing, we unfortunately can't help you.
Therefore, please edit this issue accordingly or close and create a new one and make sure to provide all the required information.
@timbru31 Thank you for your kind reply :slightly_smiling_face: . I will check with the window listener that you have mentioned in another comment.
Closing as stale.