我剛開始學習angularJS,我有我的第一個控制器的問題。控制器不使用angularJS渲染
這是我的HTML:
<!DOCTYPE html>
<html ng-app="">
<head lang="en">
<title></title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js"></script>
<script type="text/javascript" src="includes/main.js"></script>
</head>
<body>
<div ng-controller="firstCtrl">
<h1>{{data.message +" world"}}</h1>
<div class="{{data.message}}">
This is just a game!
</div>
</div>
</body>
</html>
,這是JavaScript文件main.js:
function firstCtrl ($scope){
$scope.data = {message: "Hello"};
}
教程IM
用什麼IM想看到它的Hello World消息在工作h1但我真正看到它的:
{{data.message +" world"}}
這只是一個遊戲!
這是在控制檯中的錯誤:
Error: [ng:areq] http://errors.angularjs.org/1.3.8/ng/areq?p0=firstCtrl&p1=not%20a%20function%2C%20got%20undefined
at Error (native)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js:6:416
at Qb (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js:19:417)
at sb (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js:20:1)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js:76:95
at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js:57:257
at s (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js:7:408)
at v (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js:57:124)
at g (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js:52:9)
at g (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js:52:26)
有人可以幫助我弄清楚它是什麼? 我從教程複製確切的代碼,所以我想它與我的配置的東西,但我不知道它是什麼
看到錯誤在瀏覽器的控制檯 –