$ ionicActionSheet在离子型中不起作用

时间:2019-05-23 05:58:09

标签: ionic-framework controller

我正在尝试在Web应用程序中使用$ ionicActionSheet,但无法正常工作,任何人都可以帮助我找出我的代码中的错误。在此先感谢

  • 请检查以下controllers.js文件代码

      angular.module('starter.controllers', [])
      .controller('AppCtrl', function($scope, $ionicModal, $timeout) { 
      })
    
      .controller('myCtrl', function($scope, $ionicActionSheet) {
      $scope.triggerActionSheet = function() {
       // Show the action sheet
       var showActionSheet = $ionicActionSheet.show({
       buttons: [
        { text: 'Edit 1' },
        { text: 'Edit 2' }
       ],
    
     destructiveText: 'Delete',
     titleText: 'Action Sheet',
     cancelText: 'Cancel',
    
     cancel: function() {
        // add cancel code...
     },
    
     buttonClicked: function(index) {
        if(index === 0) {
           // add edit 1 code
        }
    
        if(index === 1) {
           // add edit 2 code
        }
     },
    
     destructiveButtonClicked: function() {
        // add delete code..
     }
    });
    };
    })
    

然后请检查以下index.html文件代码:-

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>
    <link rel="manifest" href="manifest.json">
    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>
    <!-- cordova script (this will be a 404 during development) -->
    <script src="cordova.js"></script><!-- 
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script> -->
<script src="js/controllers.js"></script>
    <!-- your app's js -->
    <script src="js/app.js"></script>
    </head>
    <body ng-app="starter">
<ion-pane>
    <ion-content>
         <button class = "button">Action Sheet Button</button> 
    </ion-content>
    </ion-pane>
    </body>
    </html>

0 个答案:

没有答案