作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 Scala Play 中使用 AngularJS,我收到此错误。
Error: Argument 'MainCtrl' is not a function, got undefined
我正在尝试创建一个包含一周中各天的表格。
请看一下我的代码。我检查了 Controller 的名称,但这似乎是正确的。注意:此 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"]
}
});
}());
最佳答案
从模块名称([myApp])中删除[]
angular.module('myApp', [])
并将 ng-app="myApp"
添加到 html 中,它应该可以工作。
关于angularjs - 错误 : Argument is not a function, 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17289236/
我是一名优秀的程序员,十分优秀!