[英]ASP.Net Doesn't compile AngularJS
Good Night! 晚安!
I'm trying to implement a ASP.NET API, but I can't figure out why my angular doesn't compile correctly! 我正在尝试实现ASP.NET API,但无法弄清楚为什么我的angular无法正确编译!
I just created a new empty web Project, added angular and jquery through NUGET, and I'm trying to add the scripts like this. 我刚刚创建了一个新的空Web项目,并通过NUGET添加了angular和jquery ,并且试图添加这样的脚本。
Index.html Index.html
<!DOCTYPE html>
<html>
<head ng-app="palladarApp">
<title>CodeBranch - Palladar</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
</head>
<body ng-controller="palladarCtrl">
<div>
<header></header>
<section>{{ teste }}</section>
<hr />
<section>{{ 13 + 31 }}</section>
<footer></footer>
</div>
<!--Load Libraries-->
<link href="Content/bootstrap.min.css" rel="stylesheet" />
<script src="Scripts/jquery-2.1.4.js"></script>
<script src="Scripts/angular.js"></script>
<script src="Scripts/i18n/angular-locale_pt-br.js"></script>
<script src="Scripts/angular-route.js"></script>
<script src="Scripts/angular-animate.js"></script>
<!--Load Scripts-->
<script src="app/Controllers/palladarController.js"></script>
</body>
</html>
PalladarController.js PalladarController.js
var app = angular.module('palladarApp', []);
app.controller('palladarCtrl', ['$scope', '$http', '$modal', function($scope, $http, $modal) {
$http.defaults.headers.post['Content-Type'] = 'application/json';
$scope.teste = "HUE HUE HUE";
}]);
When I run the Project, I just saw at my browser the codes.. 运行项目时,我只是在浏览器中看到了代码。
{{ teste }}
{{ 13 + 31 }}
If I open the browser console (F12) it doesn't show any errors. 如果打开浏览器控制台(F12),则不会显示任何错误。
You need to put: ng-app="palladarApp"
inside html tag, something like this: 您需要将
ng-app="palladarApp"
放在html标记中,如下所示:
<!DOCTYPE html> <html ng-app="palladarApp"> <head> <title>CodeBranch - Palladar</title> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /> </head> <body ng-controller="palladarCtrl"> <div> <header></header> <section>{{ teste }}</section> <hr /> <section>{{ 13 + 31 }}</section> <footer></footer> </div> <!--Load Libraries--> <link href="Content/bootstrap.min.css" rel="stylesheet" /> <script src="Scripts/jquery-2.1.4.js"></script> <script src="Scripts/angular.js"></script> <script src="Scripts/i18n/angular-locale_pt-br.js"></script> <script src="Scripts/angular-route.js"></script> <script src="Scripts/angular-animate.js"></script> <!--Load Scripts--> <script src="app/Controllers/palladarController.js"></script> </body> </html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.