ionic cordova plugin add cordova-plugin-screen-orientation
<preference name="orientation" value="portrait" />
$scope.$on('$ionicView.beforeEnter', function() { if (typeof screen.orientation != 'undefined') { screen.orientation.unlock(); } }); $scope.$on('$ionicView.afterLeave', function() { if (typeof screen.orientation != 'undefined') { screen.orientation.lock('portrait'); } });