AngularJS [$ injector:modulerr] no mod' testApp'不可用

时间:2015-11-08 20:27:18

标签: javascript angularjs

这是我的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]);
})();

这是我一直在犯的错误......

  

未捕获错误:[$ injector:modulerr]由于以下原因无法实例化模块testApp:   错误:[$ injector:nomod]模块&#39; testApp&#39;不可用!您要么错误拼写了模块名称,要么忘记加载它。如果注册模块,请确保将依赖项指定为第二个参数。

有人知道为什么会出现这种错误吗?我试图创建自己的testApp模块,但由于某种原因,它在创建模块时不断抛出此错误。

1 个答案:

答案 0 :(得分:1)

您需要包含您的javascript文件以及角度库

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.29/angular.js"></script>
<script src="path/to/myscript.js"></script>
相关问题