Sorry if my english isn't perfect at all.
I am using $ionicPlatform.onHardwareBackButton to use with the Screen Orientation Plugin to change the orientation to portrait when you go back from a view when is playing a Youtube video, here is an example of what i am doing:
app.controller('nameCtrl', ['$ionicPlatform', function('$ionicPlatform') {
$scope.openVideo = function(id) {
var isVideoPlaying = true;
// some stuff here
if(isVideoPlaying) {
$ionicPlatform.onHardwareBackButton(function() {
screen.lockOrientation('portrait');
isVideoPlaying = false;
alert('going back');
});
} // in this line i get an error "TypeError: object is not a function" from GapDebug
}
}]);
onHardwareBackButton detection works perfect, but when i am not playing a video the callback function is called too. Don't know why is not working with the boolean part. Any help? Sorry if is an stupid question.
I tried using semicolon in the line of the error based on GapDebug but nothing.
Thanks in advance
Try something like this:
app.controller('nameCtrl', ['$ionicPlatform', function('$ionicPlatform') {
$scope.openVideo = function(id) {
var isVideoPlaying = true;
// some stuff here
$ionicPlatform.onHardwareBackButton(function() {
if(isVideoPlaying) {
screen.lockOrientation('portrait');
isVideoPlaying = false;
alert('going back');
} // in this line i get an error "TypeError: object is not a function" from GapDebug
});
}
}]);