如何停止 onHardwareBackButton 的回调函数?离子
How to stop callback function for onHardwareBackButton? Ionic
抱歉,如果我的英语一点也不完美。
我正在使用 $ionicPlatform.onHardwareBackButton 与屏幕方向插件一起使用,当您在播放 Youtube 视频时从视图返回时将方向更改为纵向,这是我正在做的一个例子:
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 检测工作完美,但当我不播放视频时,回调函数也会被调用。不知道为什么不使用布尔部分。有什么帮助吗?对不起,如果是一个愚蠢的问题。
我尝试在基于 GapDebug 的错误行中使用分号,但没有。
提前致谢
尝试这样的事情:
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
});
}
}]);
抱歉,如果我的英语一点也不完美。
我正在使用 $ionicPlatform.onHardwareBackButton 与屏幕方向插件一起使用,当您在播放 Youtube 视频时从视图返回时将方向更改为纵向,这是我正在做的一个例子:
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 检测工作完美,但当我不播放视频时,回调函数也会被调用。不知道为什么不使用布尔部分。有什么帮助吗?对不起,如果是一个愚蠢的问题。
我尝试在基于 GapDebug 的错误行中使用分号,但没有。
提前致谢
尝试这样的事情:
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
});
}
}]);