Reputation: 1326
I am using Ionic 3. I did
ionic cordova plugin add cordova-plugin-screen-orientation
npm install @ionic-native/screen-orientation
app.module.ts
:
import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';
@NgModule({
providers: [
ScreenOrientation,
...
On my page.ts
:
import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';
ionViewDidLoad() {
this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.LANDSCAPE);
Vs Code is not showing any error, but I get following error during runtime:
TypeError: Object(...) is not a function
at ScreenOrientation.lock(http://10.18.2.70:8100/build/vendor.js:...)
Upvotes: 0
Views: 1548
Reputation: 121
Try this:
declare var window;
ionViewDidLoad() {
window.screen.orientation.lock('landscape');
}
Upvotes: 2