2013-02-22 41 views
4

如何在這不起作用?爲了不拋出「no module:tut」錯誤,你需要什麼最低限度?angular.module裸露最小值

<!DOCTYPE html> 
<html ng-app="tut"> 
    <head> 
     <script type="text/javascript" src="./jquery.js"></script> 
     <script type="text/javascript" src="./script-ng.js"></script> 
     <script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script> 
      <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js"></script> 
     <link rel="stylesheet" href="main.css"></link> 
    </head> 
    <body> 
     <div id="sidebar_left"><div id="header"></div><ul id="nav"></ul></div> 
     <div id="container"> 


      <video id="video" controls> 

         Your browser does not support the video tag.</video> 
      <br /> 
      <button id="reset">Replay</button> 

     <br /> 
     <div ng-controller="getAnswers" id="pannel"> 
      <div id="base">{{verbs.base}}</div> 
      <ul class="answers"> 
       <li ng-click="checkAnswer($event)" ng-repeat="answer in verbs.conjugations" class="answer {{answer.correct}}" id="answer{{$index}}">{{answer.text}}</li> 
      </ul> 
     </div> 
     <br /> 
     <br /> 
     <br /> 
     <div id="warning"></div> 
    </div> 
</body> 

angular.module('tut', []).controller('getAnswers', function ($scope, $element){ 
    $scope.verbs = conjugate(conjugationsets[tutorial_number][questionnum]); 
    $scope.randomizeAnswers = function() { 
     fisherYates($scope.verbs.conjugations); 
    }(); 

    $scope.checkAnswer = function(){ 
     checkanswer(); 
    } 
}); 
+0

您的HTML的頂部缺失,所以很難說。另外,這是你的所有JavaScript?你的ngApp指令是什麼意思? – 2013-02-22 21:36:30

+0

對不起,其餘的 – Tules 2013-02-22 21:48:20

+3

我想你可能必須在你的模塊定義之前包含angular.js。 – 2013-02-22 21:49:49

回答

4

很簡單。你可能忘了這樣做,在ur js文件的頂部添加angularjs庫。

1

在大多數的應用程序,你只需要一個模塊,你的情況,你需要包括在作爲內容的父項的HTML元素NG-應用=「應用程序」你希望有角度的工作。

大多數時候是標籤這將使

如果你想分手了你的代碼用於測試目的,你可以讓多個模塊,包括它們的依賴的陣列,像這樣的名字:

angular.module('tut', [ 'othermodule', 'andanothermodule']); 

angular.module('othermodule'); 

etc. 

是的,加載你的腳本的順序是錯誤的,如Josh評論中指出的那樣。