gpt4 book ai didi

angularjs - 错误 : Argument is not a function, 未定义

转载 作者:行者123 更新时间:2023-12-03 04:36:22 26 4
gpt4 key购买 nike

在 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com