2015-11-07 67 views
0

我剛學angularjs,用下面的代碼我已經收到此錯誤==>錯誤:$注射器: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.0.4'..I會建議您使用較新的一個到達benifite更多的功能,並免費角 –

回答

1

你應該改變你的應用程序的名稱,因爲你所定義的模塊spicyApp1

來源:

<body ng-app = "myApp"> 

<body ng-app = "spicyApp1"> 

工作Plunker

+0

我看到的bug,感謝您的!非常不尋常的如何它不在鉻上工作 –

+0

@EyadAbdalla檢查工作plunker鏈接 – Sajeetharan

+0

是我在上面,我想知道爲什麼它不會在通過鉻打開它的工作 –