使用AngularJS与Scala Play,我收到此错误。
原文链接:https://www.f2er.com/angularjs/147172.htmlError: Argument ‘MainCtrl’ is not a function,got undefined
我试图创建一个表,包括一周的几天。
请看看我的代码。我检查了控制器的名称,但这似乎是正确的。注意:从这个SO answer使用的代码
index.scala.html
@(message: String) @main("inTime") { <!doctype html> <html lang="en" ng-app> <head> <link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")"> </head> <div ng-controller="MainCtrl"> <table border="1"> <tbody ng-repeat='(what,items) in data'> <tr ng-repeat='item in items'> <td ngm-if="$first" rowspan="{{items.length}}">{{what}}</td> <td>{{item}}</td> </tr> </tbody> </table> </div> </html> }
MainCtrl.js
(function() { angular.module('[myApp]',[]).controller('MainCtrl',function($scope) { $scope.data = { Colors: ["Monday","Tuesday","Wednesday","Thursday","Friday"] } }); }());