[英]AngularJS: ReferenceError: Angular is not defined
Im creating a simple App with c# WebAPI & AngularJS. 我用c#WebAPI和AngularJS创建了一个简单的应用程序。 Im getting this error in the console, the web its not working.
我在控制台中收到此错误,网络无法正常工作。
My Index.html: 我的Index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="../../Scripts/Angular.js"></script>
<script src="../Scripts/theSoft.js"></script>
<script src="../Scripts/UsersListController.js"></script>
</head>
<body>
<div ng-app="theSoft">
<div ng-controller="UsersListController">
{{ 1+1 }}
</div>
</div>
</body>
</html>
theSoft.js File: theSoft.js文件:
(function () {
var app = Angular.module("theSoft")
});
UserListController.js UserListController.js
(function (app) {
var UsersListController = function ($scope) {
$scope.message = "Guido Caffa";
};
app.controller("UsersListController", UsersListController);
}(Angular.module("theSoft")));
The error is in line 6, at the UserListController.js 错误在UserListController.js的第6行
Can anyone helpme ? 谁能帮我 ?
Thanks! 谢谢!
This demo of @Sajeetharan help me solving my problem. @Sajeetharan的此演示可帮助我解决问题。 https://next.plnkr.co/edit/XZPj3ZS1a1JmhJ6jVDQs?p=preview
https://next.plnkr.co/edit/XZPj3ZS1a1JmhJ6jVDQs?p=preview
I was using "Angular" instead of "angular". 我使用的是“角度”而不是“角度”。 And i was missing a "()" in the end of theSoft.js.
而且我在theSoft.js的末尾缺少一个“()”。
Thanks all! 谢谢大家!
You need to add a empty dependency to your module in theSoft.js 您需要在TheSoft.js中向模块添加一个空的依赖项
var app = angular.module("theSoft",[])
also make sure your reference paths are correct, 还要确保您的参考路径正确,
<script src="../../Scripts/Angular.js"></script> // should not this be ../scripts?
<script src="../Scripts/theSoft.js"></script>
<script src="../Scripts/UsersListController.js"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.