angular is not defined in Visual Studio 2015

那年仲夏 提交于 2020-01-02 09:55:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!