【问题标题】:"ngCordovaOauth is not available" error for ionic app离子应用程序的“ngCordovaOauth 不可用”错误
【发布时间】: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 &apos;self&apos; &apos;unsafe-inline&apos; &apos;unsafe-eval&apos; *; style-src  &apos;self&apos; &apos;unsafe-inline&apos; *">
<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


【解决方案1】:

虽然我确实正确安装了 ng-cordova-oauth 并且没有拼错它的名称,但我收到了同样的错误消息。
我的问题是我盲目抄袭

<script src="../ng-cordova-oauth/dist/ng-cordova-oauth.min.js"></script>

从 ng-cordova-oauth 的 README 文件到我的index.html,而路径错误!确实,正确的路径是您在问题中指定的路径:lib/ng-cordova-oauth/dist/ng-cordova-oauth.min.js!
所以,对于任何有同样问题的人,我建议在他们的index.html 中检查他们的ng-cordova-oauth.min.js 的路径。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-25
    • 1970-01-01
    • 1970-01-01
    • 2018-07-29
    • 1970-01-01
    • 2017-12-02
    • 1970-01-01
    • 2017-04-12
    相关资源
    最近更新 更多