Reputation: 33
I am just learning angularjs, with the following code I have been getting this error ==> Error: $injector:modulerr Module Error
Here is the code, what is going wrong here?
<!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>
Upvotes: 0
Views: 336
Reputation: 222682
You should change your app name, Since you are defining the module as spicyApp1
From:
<body ng-app = "myApp">
To
<body ng-app = "spicyApp1">
Working Plunker
Upvotes: 1