【发布时间】:2016-05-26 18:33:09
【问题描述】:
我在 Android 上有一个 Ionic 应用程序,我想使用 ngCordovaOauth 插件添加 Facebook 登录功能,但我得到了:
0 851065 error Uncaught Error: [$injector:modulerr] Failed to instantiate module
starter due to:
Error: [$injector:modulerr] Failed to instantiate module ngCordovaOauth due to:
Error: [$injector:nomod] Module 'ngCordovaOauth' is not available! You either misspelled
the module name or forgot to load it. If registering a module ensure that you specify
the dependencies as the second argument.
....
我尝试根据here加载插件。我用 bower 加载插件
bower install ng-cordova-oauth -S
然后我将这一行添加到 index.html
<script src="lib/ng-cordova-oauth/dist/ng-cordova-oauth.min.js"></script>
之后,我将依赖添加到模块 app.js
angular.module('starter', ['ionic','ngMessages','ngCordova','ngCordovaOauth','ksSwiper','starter.services','starter.controllers'])
当我添加“ngCordovaOauth”时出现错误。我还尝试手动下载 ng-cordova-oauth.min.js 文件并将其添加到 www/js 文件夹并添加
<script src="js/ng-cordova-oauth.min.js"></script>
到 index.html 文件后,我通过凉亭卸载。这也没有奏效。我也试过把安卓平台去掉再重新添加,还是不行。
我想我尝试了我能做的一切,但似乎不起作用。它应该找到 ngCordovaOauth,但它没有。任何帮助表示赞赏。
提前致谢。
编辑
index.html:
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Security-Policy" content="default-src *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; style-src 'self' 'unsafe-inline' *">
<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="lib/swiper/dist/css/swiper.min.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>
<script src="lib/ngCordova/dist/ng-cordova.js"></script>
<script src="lib/swiper/dist/js/swiper.js"></script>
<script src="lib/angular-swiper/dist/angular-swiper.js"></script>
<script src="js/angular-messages.js"></script>
<script src="lib/ng-cordova-oauth/dist/ng-cordova-oauth.min.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/services.js"></script>
<script src="js/controllers.js"></script>
【问题讨论】:
-
您尝试将脚本包含在 index.html 文件中的什么位置?
-
我编辑了问题
-
您安装了哪个版本的 ng-cordova? v0.1.24-alpha 是修复 OAuth 依赖问题的版本。
-
我检查了 0.1.23 的版本。我更新到 0.1.24 但没有解决我的问题。我仍然得到同样的错误。
-
@gkocyigit 确保您删除并重建;
标签: angularjs cordova ionic-framework cordova-plugins ngcordova