javascript - 为什么我的 Angular JS 应用程序无法运行?

标签 javascript angularjs html debugging

这里是firstAngularJSApp.html

<html ng-app="store"><!-- "ng-app" creates and angular app by running the module. because of ng-app html inside of this tag will be treated as part of angular app --> 
<head>
    <link rel="stylesheet" type="text/css" href="bootstrap.min.css"/>
    <script type="text/javascript" src="angular.min.js"></script>
    <script type="text/javascript" src="app.js"/>
</head>
<body>

<p>I am {{ 4+6 }}</p>

</body>
</html>

这里是app.js

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

当我加载页面时,我没有得到“我是 10”,而是空白页面。但是当我使用 Ctrl+U 打开源代码时我可以看到"<p>I am {{ 4+6 }}</p>"

enter image description here

我正在使用 XAMMP 访问我的文件。

最佳答案

您正在使用自动关闭的 script 标记,该标记不起作用。请参阅Why don't self-closing script tags work?

因此,您的 app.js 文件不包含在页面中,并且您的 Angular 应用程序未引导。

使用

<script type="text/javascript" src="app.js"></script>

此外,请确保文件路径正确。

关于javascript - 为什么我的 Angular JS 应用程序无法运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32602550/

相关文章:

javascript - 为什么我的 `then` 事件在我的 `when` 事件完成之前触发?

angularjs - 将 polymer 组件和 Angular Controller 连接在一起

javascript - angularjs 中的 ng-show 不适用于 span

javascript - 带有 Angular Directive(指令)的样式复选框

html - Accordion 中的按钮位置

javascript - 无法获取输入 ionic 3 的值

确保文本仅包含格式为 $placeholder$ 的美元符号的 JavaScript 函数

javascript - 为什么 `{foo: function myName() {}}` 是可接受的语法?

javascript - 修改方法以完成从数组中删除空字符串的额外逗号

java - 无法使用 jSoup 发布