抱歉,如果我的英语一点也不完美。
我使用 $ionicPlatform.onHardwareBackButton 与屏幕方向插件一起使用,当您在播放 Youtube 视频时从 View 返回时,将方向更改为纵向,这是我正在做的示例:
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 检测工作完美,但是当我不播放视频时,也会调用回调函数。不知道为什么不能使用 bool 部分。有什么帮助吗?抱歉,这是一个愚蠢的问题。
我尝试在基于 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
});
}
}]);
关于javascript - 如何停止onHardwareBackButton的回调函数? ionic ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28753071/