我试图禁用我的科尔多瓦应用程序中的后退按钮。我使用AngularJS +离子框架。我发现这个主题,并试图在code波纹管,但是它绝对没有任何影响。任何想法?谢谢!
I'm trying to disable the back button on my Cordova app. I'm using AngularJS + Ionic Framework. I found topics about this and tried the code bellow, but it has absolutely no effect. Any idea? Thanks!
index.html的
index.html
<head> <script> document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { document.addEventListener("backbutton", function (e) { e.preventDefault(); console.log("hello"); }, false ); } </script> </head>请注意,当我按下后退按钮,我有你好显示在我的控制台。
Note that when I push back button, I have "hello" displayed in my console.
推荐答案终于找到了对离子论坛线程答案:
Finally found the answer on Ionic Forum thread:
forum.ionicframework/t/handling-the-hardware-back-buttons/1505/7
$ionicPlatform.registerBackButtonAction(function () { if (condition) { navigator.app.exitApp(); } else { handle back action! } }, 100);$ ionicPlatform.registerBackButtonAction允许完全地覆盖后退按钮行为。第一个参数是一个回调函数和secondone优先级(仅具有最高优先级被执行回调)。
$ionicPlatform.registerBackButtonAction allows to completly overwrite back button behavior. First param is a callback function and the secondone a priority (only the callback with the highest priority gets executed).
更多推荐
在离子应用程序禁用硬件后退按钮?
发布评论