Can't lock screen orientation?

Hi all.

I have the following in my controller::

  document.addEventListener("deviceready", onDeviceReady, false);
   
  function onDeviceReady(){
     console.log("LOCKING SCREEN!!");
     screen.lockOrientation('portrait'); 
  }

And I have the screen orientation plugin installed: github:

C:\my_project\trunk>cordova plugin add cordova-plugin-screen-orientation
Fetching plugin "cordova-plugin-screen-orientation" via npm
Plugin "cordova-plugin-screen-orientation" already installed on android.

No error messages appear, and the “LOCKING SCREEN” arrives fine in the console log. Yet, the screen isn’t locked at all? Any ideas?

Hii…
Try adding <preference name="orientation" value="portrait" /> in config.xml file…

Hi, Thanks! It worked. But I have one view though, were I actually need the orientation to be unlocked?

Yes…
all you need to do is just remove that preference tag from config.xml