angular在Visual Studio 2015中未定义 [英] angular is not defined in Visual Studio 2015

查看:183
本文介绍了angular在Visual Studio 2015中未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2015中创建了一个开箱即用的cordova应用程序,然后使用NuGet Manager添加了AngularJS.Core库。



.js文件在我的html文件,并试图运行该项目,我一直收到这个错误:



angular未定义


$ b b

这里是我的html页面示例:



您的应用程序已准备好!

 < div ng-app =module1ng-controller =Ctrl1> 
< p> {{Test}}< / p>
< / div>

< script src =../ Scripts / angular.min.js>< / script>

<! - Cordova引用,这是添加到您的应用程序时,它的构建。 - >
< 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>

解决方案>

此问题的解决方案如下。您不应在任何Cordova项目应用程序中引用www文件夹之外的任何文件。



使用Visual Studio NuGet包管理器添加的所有 JS 脚本文件夹,不适用于Cordova应用程序。要允许Cordova应用访问 JS 文件,请将任何必需的库从Scripts文件夹复制到www文件夹下的任何位置。





希望这有帮助。



PS :同样适用于字体样式表


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>

解决方案

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.

这篇关于angular在Visual Studio 2015中未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆