继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

ionic上拉菜单解析(学习笔记)

聂小恶
关注TA
已关注
手记 4
粉丝 2
获赞 6
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no,width=device-width">
    <link rel="stylesheet" href="../framework/ionic/css/ionic.css">
    <script src="../framework/ionic/js/ionic.bundle.js"></script>
</head>
    <body ng-app="starter" ng-controller="actionsheetCtl">
        <ion-pane>
            <ion-content>
                <h2 ng-click="show()">Action Sheet</h2>
            </ion-content>
        </ion-pane>
    </body>

    <script>
        angular.module('starter',['ionic'])
                .run(function ($ionicPlatform) {
                    $ionicPlatform.ready(function () {
                        if(window.cordova && window.cordova.plugins.Keyboard){
                            cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
                        }
                        if(window.StartusBar){
                            StatusBar.styleDefault();
                        }
                    });
                })
                .controller('actionsheetCtl',['$scope','$ionicActionSheet','$timeout',function ($scope,$ionicActionSheet,$timeout) {
                    $scope.show=function () {
                        var hideSheet=$ionicActionSheet.show({
                            buttons:[
                                {text:'<b>Share</b> This'},
                                {text:'Move'}
                            ],
                            destructiveText:'Delete',  //destructive破坏性的        样式:文字颜色为红色
                            titleText:'Modify your album',      ///将会位于上拉菜单的头部位置
                            cancelText:'Cancel',//位于上拉菜单的尾部,且与主体之间存在间隙
                            cancel:function () {
                                //add cancel code
                                //这里是上拉菜单收回会将要执行的代码
                            },
                            buttonClicked:function (index) {
                                alert('你点击了第'+index+'个按钮')
                                //index下标从0开始
                                //这里的代码是点击button后将要执行的代码,button为上面定义的数组
                                return true;
                            }
                        });
                        $timeout(function () {
                            alert('再见')
                            //这里为设置的显示时长
                            hideSheet();
                        },2000);
                    };

                }])

    </script>
</html>
打开App,阅读手记
1人推荐
发表评论
随时随地看视频慕课网APP

热门评论

怎么用destructiveText来做个删除事件呢


查看全部评论