错误:$ injector:modulerr模块错误angularjs

时间:2015-11-07 05:43:31

标签: angularjs angularjs-controller

我只是在学习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>

1 个答案:

答案 0 :(得分:1)

您应该更改您的应用名称,因为您将模块定义为 spicyApp1

来自:

<body ng-app = "myApp">

 <body ng-app = "spicyApp1">

工作Plunker