我只是在学习angularjs,用以下代码我得到了这个错误==>错误:$ injector:modulerr 模块错误
这是代码,这里出了什么问题?
<!doctype html>
<html lang="en">
<head>
<title>js</title>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.js"
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular- resource.min.js">
</script>
</head>
<body ng-app = "myApp">
<div ng-controller="SpicyController">
<button ng-click="chiliSpicy()">Chili</button>
<button ng-click="jalapenoSpicy()">Jalapeño</button>
<p>The food is {{spice}} spicy!</p>
</div>
<script>
var myApp = angular.module('spicyApp1', []);
myApp.controller('SpicyController', function($scope) {
$scope.spice = 'very';
$scope.chiliSpicy = function() {
$scope.spice = 'chili';
};
$scope.jalapenoSpicy = function() {
$scope.spice = 'jalapeño';
};
});
</script>
</body>
</html>
答案 0 :(得分:1)
您应该更改您的应用名称,因为您将模块定义为 spicyApp1
来自:
<body ng-app = "myApp">
要强>
<body ng-app = "spicyApp1">
工作Plunker