Used the below implementation for screen rotation plugin:
import { ScreenOrientation } from ‘@ionic-native/screen-orientation/ngx’;
Below
this.screenOrientation.onChange().subscribe(
() => {
console.log(‘Orientation Changed’);
}
);
Error:
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 ProjectListPage.push…/src/app/page-routing/project-list/project-list.page.ts.ProjectListPage.ngAfterViewInit (project-list.page.ts:60)
at callProviderLifecycles (core.js:22416)
at callElementProvidersLifecycles (core.js:22390)
at callLifecycleHooksChildrenFirst (core.js:22380)
at checkAndUpdateView (core.js:23316)
at callWithDebugContext (core.js:24177)
Finally in a few cases, I listened for the window:resize event, which I found worked better then listening for the window:orientation event:
<!-- window:resize works more consistently then window:orientation, for some reason -->
<ion-content (window:resize)="checkOrientation()">
... html here ...