I've been working on an app using AngularJS. Now, I'm ready to take my app and bundle it up with Cordova. My issue is, I'm not sure how to handle the ondeviceready
event. At this time, my app is setup like this:
index.html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="/app/app.js"></script>
</head>
<body>
...
<script type="text/javascript">
if (window.location.protocol === "file:") {
document.addEventListener('deviceready', initializeApp(), false);
} else {
initializeApp();
}
</script>
</body>
</html>
app.js
function initializeApp() {
var myApp = angular.module('myApp', ['ngRoute']);
myApp.config(function() {
...
});
myApp.run(function() {
...
});
}
I put the initialization in a function called initializeApp so I could reuse it. However, when I attempt to run this, I'm getting an error that says...
Uncaught ReferenceError: initializeApp is not defined
What am I doing wrong?