【发布时间】:2015-11-28 11:28:53
【问题描述】:
我有一个小问题。 我在 Visual Studio 2015 中启动了一个空的 Cordova 应用程序,只是为了进行一些测试,我想在我的应用程序中尝试 ng-cordova 插件(没有离子)。我遵循 ng cordova 文档,并在 cordova.js 之前和 angular.js 文件之后添加了 ng-cordova.min.js 文件。我没有在我的 index.html 文件中添加任何内容,并且在我编写的 cordova js 文件之后调用的脚本中:
(function () {
"use strict";
document.addEventListener( 'deviceready', onDeviceReady.bind( this ), false );
function onDeviceReady() {
var app_ng=angular.module('myApp', ['ngCordova']);
console.log('device ready');
$cordovaFile.getFreeDiskSpace()
.then(function (success) {
console.log(success);
}, function (error) {
console.log(error);
});
};
} )();
<html>
<head>
<meta charset="utf-8" />
<!--
Customize the content security policy in the meta tag below as needed. Add 'unsafe-inline' to default-src to enable inline JavaScript.
For details, see http://go.microsoft.com/fwlink/?LinkID=617521
-->
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
<title>ngcordovatest</title>
<!-- ngcordovatest references -->
<link href="css/index.css" rel="stylesheet" />
</head>
<body ng-app="myApp">
<p>Hello, your application is ready!</p>
<div id="console">
</div>
<!-- Cordova reference, this is added to your app when it's built. -->
<script src="scripts/jquery.js"></script>
<script src="scripts/angular.min.js"></script>
<script src="scripts/ng-cordova.min.js"></script>
<script src="scripts/ng-cordova-mocks.min.js"></script>
<script src="cordova.js"></script>
<script src="scripts/platformOverrides.js"></script>
<script src="scripts/index.js"></script>
</body>
</html>
我总是收到以下错误:
Uncaught ReferenceError: $cordovaFile is not defined
我使用通过 USB 连接的 android 设备进行调试。
有什么问题?我想不通。谢谢你。
【问题讨论】:
标签: android angularjs cordova plugins ngcordova