我正在尝试创建基本的角度应用,但它会抛出错误
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
<script type="text/javascript">
var angularApp = angular.module('angularApp', []);
angularApp.controller('Ctrl', function($scope) {});
</script>
</head>
<body>
<div ng-app ng-controller="Ctrl"></div>
</body>
</html>
错误:
Error: [ng:areq] http://errors.angularjs.org/1.4.3/ng/areq?p0=Ctrl&p1=not%20a%20function%2C%20got%20undefined
at Error (native)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:6:416
at Sb (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:22:18)
at Qa (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:22:105)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:79:497
at x (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:59:501)
at S (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:60:341)
at g (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:54:384)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:53:444
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:19:481'
我做错了什么?
答案 0 :(得分:6)
您必须提供ng-app
应用名称:
<div ng-app="angularApp" ng-controller="Ctrl"></div>