【问题标题】:why my web application can't recognize angular.js为什么我的 Web 应用程序无法识别 angular.js
【发布时间】:2014-10-26 11:45:57
【问题描述】:

我是 Angular 的初学者,我正在尝试在我的 Web 应用程序 (VS) 中加载和使用它,但每次我在识别 Angular 时遇到问题,我不知道为什么...我尝试了不同的方法,但都有相同的输出 - 不识别角度

  1. 我从 angular 网站下载 angular.min.js 并从我的页面添加指向此 js 文件夹的链接

  2. 试过<script src="Scripts/angular.js"></script>没有变化...

  3. 尝试使用包管理器控制台:PM> Install-Package angularjs 添加成功...

这是来自我的 HTML 页面的完整代码...

<html xmlns="http://www.w3.org/1999/xhtml" data-ng-app="test">
<head runat="server">
    <script src="Scripts/angular.min.js"></script>
    <script src="Scripts/app.js"></script>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    </div>
    </form>
</body>
</html>

//app.js

 (function () {

        var app = angular.module('test',[]);

    });

*更新:我收到此错误:

Unhandled exception at line 7, column 218 in http://localhost:4191/Scripts/angular.min.js

0x800a138f - JavaScript runtime error: Object expected

解决方案:我使用了 angular.min.js - 将其更改为 src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.js"。问题解决了。

【问题讨论】:

  • 不识别怎么办?
  • 抱歉,我收到此错误:localhost:4191/Scripts/angular.min.js 0x800a138f 中第 7 行第 218 列未处理的异常 - JavaScript 运行时错误:预期对象
  • 请向我们展示您的 app.js 文件。如果您将其添加到您的问题中,那就太好了。
  • KryDos - 做到了,谢谢。
  • 不需要使用 (function(){})。请删除它。

标签: javascript angularjs web-applications


【解决方案1】:

根据this SO question上的cmets,页面需要以下标记

<meta http-equiv="X-UA-Compatible" content="IE=edge">

【讨论】:

  • 这对我有用。使用 IE 10 和 AngularJS v1.4.3。
猜你喜欢
  • 2016-05-28
  • 1970-01-01
  • 1970-01-01
  • 2013-03-19
  • 1970-01-01
  • 1970-01-01
  • 2019-10-23
  • 2020-07-14
  • 2018-07-05
相关资源
最近更新 更多