【问题标题】:Ionic Mobile First IntegrationIonic 移动优先集成
【发布时间】:2016-05-19 09:01:33
【问题描述】:

我使用以下链接开发了 Ionic Side Menu 应用程序并集成了 IBM MobileFirst Platform Foundation 7.1。

https://www.raymondcamden.com/2015/03/23/working-with-ibm-mobilefirst-and-the-ionic-framework/

当我尝试构建并运行它时抛出错误

worklight.js:5383 未捕获的异常:未捕获的错误: [$injector:modulerr] 无法实例化模块 ng,原因是: TypeError:无法将属性“aHrefSanitizationWhitelist”设置为 null 在 $$SanitizeUriProvider

我用谷歌搜索并找到了下面的堆栈溢出链接,但尝试使用最新的 Angular 版本仍然是同样的问题。

IBM MobileFirst Platform Foundation 7.1
Java SDK 1.8
IONIC 版本 1.7.14

app.js

// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
// 'starter.controllers' is found in controllers.js
angular.module('starter', ['ionic', 'starter.controllers'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
   /* if (window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
      cordova.plugins.Keyboard.disableScroll(true);

    }*/
    if (window.StatusBar) {
      // org.apache.cordova.statusbar required
      StatusBar.styleDefault();
    }
  });
})

.config(function($stateProvider, $urlRouterProvider) {
  $stateProvider

    .state('app', {
    url: '/app',
    abstract: true,
    templateUrl: 'templates/menu.html',
    controller: 'AppCtrl'
  })

  .state('app.search', {
    url: '/search',
    views: {
      'menuContent': {
        templateUrl: 'templates/search.html'
      }
    }
  })

  .state('app.browse', {
      url: '/browse',
      views: {
        'menuContent': {
          templateUrl: 'templates/browse.html'
        }
      }
    })
    .state('app.playlists', {
      url: '/playlists',
      views: {
        'menuContent': {
          templateUrl: 'templates/playlists.html',
          controller: 'PlaylistsCtrl'
        }
      }
    })

  .state('app.single', {
    url: '/playlists/:playlistId',
    views: {
      'menuContent': {
        templateUrl: 'templates/playlist.html',
        controller: 'PlaylistCtrl'
      }
    }
  });
  // if none of the above states are matched, use this as the fallback
  $urlRouterProvider.otherwise('/app/playlists');
});
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 href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- 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/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>window.$ = window.jQuery = WLJQ;</script>

    <!-- your app's js -->
    <script src="js/app.js"></script>
    <script src="js/controllers.js"></script>
     <script src="js/wlinit.js"></script>
  </head>

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

【问题讨论】:

  • 请出示app.jsindex.html
  • 我编辑了问题,请找到它
  • 我没有在您的代码中看到对 SanitizeUriProvider 的引用,您是否有适当的脚本并在您的应用程序中引用?
  • SanitizeUriProvider 在 ionic.bundle.js 中
  • 您是否在 Angular 模块中添加了对 ng-sanitize 的引用?

标签: angularjs ionic-framework ibm-mobilefirst


【解决方案1】:

由于 Angular 似乎是唯一发生变化的变量,因此这可能是 Angular 问题。

我建议尝试这个的更新版本

https://github.com/csantanapr/mfp-ionic-templates

【讨论】:

  • 按照建议,我尝试使用 ionic 版本 1.2.4,然后出现 localhost 错误,我还尝试使用 ionic 1.3.22,然后得到相同的错误:worklight.js:5383 Uncaught Exception: Uncaught Error: [$ injector:modulerr] 无法实例化模块 ng,原因是:TypeError: Cannot set property 'aHrefSanitizationWhitelist' of null at $$SanitizeUriProvider
【解决方案2】:

更新:MobileFirst Platform Foundation 7.1 现在支持 Angular 1.5;从 IBM Fix Central 升级到最新的可用 iFix。

Angular 1.5 和 MFP 7.1 之间不兼容。

要使用 MFP 7.1 成功制作 Ionic 应用程序,必须使用 1.3 以下的 ionic 版本(1.2.4 Copenhagen 是最新的)。

Ionic 1.3 引入了 Angular 1.5

【讨论】:

  • @MadhuMadhuri 您是否在模拟器/本机而不是预览版上尝试过?
  • 我没有在模拟器中尝试过。我只是运行并预览应用程序
  • @MadhuMadhuri 也可以使用模拟器尝试我的回答。如果失败请告诉我!
  • Idan - 这也是 MFP 8.0 的 Cordova 项目的问题。不仅仅是 MFP 7.1
  • 最好打开 PMR。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多