我正在尝试让Mobiscroll与Ionic合作,但似乎无法实现这一目标?

这是我想要做的。我已经实现了jquery和mobiscroll像这样:

<!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 href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <link href="css/mobiscroll.custom-2.14.4.min.css" rel="stylesheet" type="text/css" />

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
    <link href="css/ionic.app.css" rel="stylesheet">
    -->

    <!-- ionic/jquery js -->
    <script src="lib/jquery/jquery-1.11.3.js"></script>

    <!-- 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>

    <!-- your app's js -->
    <script src="js/app.js"></script>
    <script src="js/controllers.js"></script>
    <script src="js/mobiscroll.custom-2.14.4.min.js"></script>
  </head>

  <body ng-app="myApp">
    <ion-nav-view></ion-nav-view>
  </body>
</html>


然后,我在controllers.js中做到了:

angular.module('myApp.controllers', [])

.controller('mobiCtrl', function ($scope) { // create controller for the module
    // create function which calculates the age given the birthday as a datetime object
    $scope.settings = {
        theme: 'ios',
        display: 'bottom',
        group: true
    };
});


最后在我的start.html中做到了:

<ion-view view-title="Start">
  <ion-content ng-controller="MyController">

    <div ng-controller="mobiCtrl">
        <select ng-model="myselect" mobiscroll-select="settings">
            <optgroup label="A">
                <option value="Alan">Alan</option>
                <option value="Anderson">Anderson</option>
            </optgroup>
            <optgroup label="E">
                <option value="Eva">Eva</option>
                <option value="Esther">Esther</option>
            </optgroup>
            <optgroup label="M">
                <option value="Michael">Michael</option>
                <option value="Margared">Margared</option>
            </optgroup>
        </select>
    </div>

  </ion-content>
</ion-view>


现在,未显示Mobiscroll,但显示了常规选择字段!

我已经在网上搜索了有关此内容的教程,但是没有运气...有没有人成功将Mobiscroll与ionic集成在一起,或者这做错了吗?

最佳答案

这很可能是因为您尚未注入mobiscroll select模块。我知道您提到了jquery,但是我认为您正在尝试角度实现,因为您正在作用域上创建设置对象。

这将解决您的问题,或者至少使您更进一步:

angular.module('myApp.controllers', ['mobiscroll-select'])

09-25 21:32