我得到以下例外......
ReferenceError:未定义cordova 在cordova.addConstructor(function()
的index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<!-- ionic css -->
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/index.css" />
<link rel="stylesheet" href="libs/leaflet/leaflet.css" />
<!--<link rel="stylesheet" href="libs/leaflet/leaflet-routing-machine.css" />-->
<!--[if lte IE 8]>
<link rel="stylesheet" href="libs/leaflet/leaflet.ie.css" />
<![endif]-->
<!-- ionic/angularjs scripts -->
<title>"Test App"</title>
<script type="text/javascript" src="cordova.js"></script>
</head>
<body ng-app="starter" animation="slide-left-right-ios7">
<!--
The nav bar that will be updated as we navigate between views
Additional attributes set its look, ion-nav-bar animation and icons
Icons provided by Ionicons: http://ionicons.com/
-->
<!--
The views will be rendered in the <ion-nav-view> directive below
Templates are in the /templates folder (but you could also
have templates inline in this html file if you'd like).
-->
<ion-nav-view></ion-nav-view>
<div id="time"></div>
<input type="hidden" value="" id="currentLatitude"/>
<input type="hidden" value="" id="currentLongitude"/>
<script type="text/javascript" src="cordova.js"></script>
<script src="lib/ionic/js/ionic.bundle.js"></script>
<!--<script type="text/javascript" src="js/jquery-2.0.3.min.js"></script>-->
<script src="libs/leaflet/leaflet.js"></script>
<!--<script type="text/javascript" src="js/core.js"></script>-->
<script src="libs/leaflet/angular-leaflet-directive.min.js"></script>
<!--<script src="libs/leaflet/leaflet-routing-machine.min.js"></script>-->
<!-- cordova script (this will be a 404 during development) -->
<!-- your app's script -->
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyAEWnOhu5ePxhmZ1Cx7ZgcamoRvN88mw2Y&sensor=true"></script>
<script type="text/javascript" src="js/samplePlugin.js"></script>
<script type="text/javascript">
document.addEventListener('deviceready', function()
{
alert("HI1")
window.plugins.SamplePlugin.getTime
(
function(result)
{
alert("HI2")
displayTime(result)
},
function(error)
{
console.log(error)
}
);
}, true
);
function displayTime(result)
{
document.getElementById("time").innerHTML = result.time;
}
</script>
</body>
</html>
和
samplePlugin.js
var SamplePlugin = function()
{
};
SamplePlugin.prototype.getTime = function(successCallback, failureCallback)
{
return cordova.exec(
successCallback, //Function called upon success
failureCallback, //Function called upon error
'ExamplePlugin', //Tell PhoneGap to run "ExamplePlugin" Plugin
'getTime', //Tell the which action we want to perform, matches an "action" string
[]); //A list of args passed to the plugin, in this case empty
};
cordova.addConstructor(function()
{
cordova.addPlugin("SamplePlugin", new SamplePlugin());
});
我已经按照本教程
了