我寫了這個簡單的代碼作爲學習練習,但我不明白爲什麼我在我的瀏覽器中得到錯誤的結果。爲什麼我的角碼不工作?
結果我在瀏覽器中看到的是文字「{{helloMessage}}」而不是的 「Hello World」。
代碼:
<!DOCTYPE html>
<html lang="en" ng-app>
<head>
<meta charset="UTF-8">
<title>Hello World</title>
</head>
<body>
<h1 ng-controller="HelloWorldCtrl">{{helloMessage}}</h1>
<script src="angular.js"></script>
<script type="text/javascript">
function HelloWorldCtrl($scope){
$scope.helloMessage = "Hello World";
}
</script>
</body>
</html>
這是輸出的,我沒有看到在瀏覽器中的任何錯誤:
你的錯誤是什麼? –
可能是angular.js導入不正確!!! –
angular.js確實可以正確導入。 – Yanshof