不知道这里发生了什么!
我一直收到错误:
Error: Argument 'TasksController' is not a function, got undefined
at qa (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js:16:79)
at ra (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js:16:187)
at $get (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js:50:411)
at $get.f (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js:42:146)
at m (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js:6:312)
at j (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js:42:8)
at e (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js:38:207)
at e (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js:38:224)
at e (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js:38:224)
at e (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js:38:224)
ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js:60
以下是我的LiveScript /Scripts/app.txt
文件:
TasksController = (scope) ->
scope.tasks = ["a", "b"]
这是我的HTML:
<!DOCTYPE html>
<html lang="en" ng-app>
<head>
<link href="/Styles/site.css" rel="stylesheet" />
<link href="/Styles/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
<link href="/Styles/bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script src="/Scripts/bootstrap.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js"></script>
</head>
<body>
<div ng-controller="TasksController">
<ul>
<li ng-repeat="task in tasks">
{{task}}
</li>
</ul>
</div>
<script type="text/ls" src="/Scripts/app.txt"></script>
<script src="/Scripts/livescript.js"></script>
</body>
</html>
答案 0 :(得分:1)
为了完整起见,这就是我想到的。
首先编译livescript文件(例如,使用Node Livescript编译器)。否则,“livescript.js”(内联编译器)在解释AngularJS的脚本文件以及及时调用它时会为时已晚。