问题
I have created an out-of-the box cordova app in Visual Studio 2015, then i added AngularJS.Core library using NuGet Manager.
After referencing the angular.js file in my html file, and tried to run the project i keep getting this error:
angular is not defined
here is a sample of my html page:
Hello, your application is ready!
<div ng-app="module1" ng-controller="Ctrl1">
<p>{{Test}}</p>
</div>
<script src="../Scripts/angular.min.js"></script>
<!-- Cordova reference, this is added to your app when it's built. -->
<script src="cordova.js"></script>
<script src="scripts/platformOverrides.js"></script>
<script src="scripts/index.js"></script>
<script src="scripts/app.js" ></script>
<script src="scripts/modules/module1/controllers.js"></script>
回答1:
The resolution for this issue is the following. You should not reference any files outside www folder in any Cordova project app.
All JS libraries added using Visual Studio NuGet package manager are added under Scripts folder outside www, which is not helpful in case of Cordova apps. To allow Cordova app to access JS files, copy any required libraries from the Scripts folder to any location under the www folder.
For example: "www-->scripts" as per your project structure and it will work!
Hope this helps.
PS: Same applies to Fonts, and Stylesheets.
来源:https://stackoverflow.com/questions/31393816/angular-is-not-defined-in-visual-studio-2015