这怎么会不起作用呢?要让它不抛出"no module: tut“错误,至少需要多少?
<!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();
}
});发布于 2013-02-24 14:45:45
非常简单。您可能忘记了这样做,jus在您的js文件的顶部添加angularjs库。
发布于 2013-02-23 05:35:03
在大多数应用程序中,您只需要一个模块,在本例中,您需要在HTML元素中包含ng-app="app“,该元素是您希望angular处理的内容的父元素。
大多数情况下,这就是它的标签
如果您想拆分代码以进行测试,您可以创建多个模块,并将它们的名称包含在依赖项数组中,如下所示:
angular.module('tut', [ 'othermodule', 'andanothermodule']);
angular.module('othermodule');
etc.是的,正如Josh在评论中指出的那样,加载脚本的顺序是错误的。
https://stackoverflow.com/questions/15033516
复制相似问题