我在 Visual Studio 2015 中创建了一个开箱即用的 cordova 应用程序,然后使用 NuGet Manager 添加了 AngularJS.Core 库。
在我的 html 文件中引用 angular.js 文件并尝试运行该项目后,我不断收到此错误:
角度未定义
这是我的 html 页面的示例:
您好,您的申请已准备就绪!
<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>
最佳答案
此问题的解决方案如下。您不应在任何 Cordova 项目应用程序中引用 www 文件夹之外的任何文件。
使用 Visual Studio NuGet 包管理器添加的所有 JS 库都添加在 www 外部的 Scripts 文件夹下,这对于 Cordova 应用程序没有帮助。要允许 Cordova 应用程序访问 JS 文件,请将任何所需的库从 Scripts 文件夹复制到 www 文件夹下的任何位置。
例如:根据您的项目结构“www-->scripts”,它将起作用!
希望这有帮助。
PS:同样适用于字体和样式表。
关于cordova - Visual Studio 2015 中未定义 Angular,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31393816/