这里是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>"
我正在使用 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/