2015-11-08 44 views
2

這裏是我的html文件:

<!DOCTYPE html> 
<html ng-app="testApp"> 

    <head> 
    <link rel="stylesheet" href="style.css" /> 
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.29/angular.js"></script> 
    </head> 

    <body> 
    <div ng-controller="TileController" class="finder-info-square"> 
      // code.... 
    </div> 
    </body> 
</html> 

這裏是我的JavaScript文件:

(function(){ 
    var app = angular.module("testApp", []); 

    var TileController = function($scope){ 
     // do stuff.... 
    }; 

    app.controller("TileController", ["$scope", TileController]); 
})(); 

這是錯誤我不斷收到...

Uncaught Error: [$injector:modulerr] Failed to instantiate module testApp due to: Error: [$injector:nomod] Module 'testApp' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

有沒有人知道爲什麼會發生這個錯誤?我試圖創建我自己的testApp模塊,但由於某種原因,它在創建模塊時不斷拋出此錯誤。

回答

1

您需要包括你的JavaScript文件以及角庫

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.29/angular.js"></script> 
<script src="path/to/myscript.js"></script> 
+0

哦男人我真是個白癡。我完全忘記了在我的源文件中添加。謝謝! :d –

相關問題