ionic android返回鍵

來源:互聯網
上載者:User

標籤:$scope   自訂   details   dex   csdn   des   current   退出   java   

每次點擊返回鍵只會執行一個事件, 在自訂事件中要控制條件不滿足時實行原預設動作. 如果只在一個view中監控, 還需要及時登出事件.

http://www.jianshu.com/p/b567cc657a49
http://blog.csdn.net/liangyiyiliang/article/details/53507411

// 返回鍵, view:100, 條件不滿足再執行預設事件$scope.homebackregister = $ionicPlatform.registerBackButtonAction(function(event) {    function showConfirm() {        var confirmPopup = $ionicPopup.confirm({            title: ‘<strong>退出應用?</strong>‘,            template: ‘你確定要退出嗎?‘,            okText: ‘退出‘,            cancelText: ‘取消‘        });        confirmPopup.then(function(res) {            if (res) {                ionic.Platform.exitApp();            } else {                $rootScope.backcount = 0;            }        });    }    if ($state.$current.name == ‘home.index‘) {        $rootScope.backcount = $rootScope.backcount || 0;        $rootScope.backcount++;        if ($rootScope.backcount == 2) {            showConfirm();        }        event.preventDefault();        return false;    } else {        navigator.app.backHistory();    }}, 101);//只在當前view下註冊, 退出即登出事件$scope.$on(‘$destroy‘, $scope.homebackregister);

ionic android返回鍵

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.