这是我的 index.gsp
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<title>my app</title>
</head>
<body>
<input type="text" data-ng-model="test"/>
{{test}}
</body>
<script src="/js/angular.min.js"></script>
</html>
当我构建应用程序时,出现这样的错误,
Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.3.15/$injector/modulerr?p0=myApp&p1=Error%3A%…20at%20d%20(http%3A%2F%2Flocalhost%3A8000%2Fjs%2Fangular.min.js%3A17%3A381)
(anonymous function) @ angular.min.js:6
(anonymous function) @ angular.min.js:35
r @ angular.min.js:7
g @ angular.min.js:34
ab @ angular.min.js:38
d @ angular.min.js:17
uc @ angular.min.js:18
Jd @ angular.min.js:17
(anonymous function) @ angular.min.js:250
a @ angular.min.js:164
c @ angular.min.js:32
最佳答案
你得到的错误说:
Failed to instantiate module myApp due to: {1}
这基本上意味着 Angular 无法创建
myApp
的实例.您可能希望至少拥有以下代码:var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
}
并在您的 HTML 中:
<html ng-app="myApp">
<head>
<title>my app</title>
</head>
<body ng-controller="MyCtrl">
<input type="text" data-ng-model="test"/>
{{test}}
</body>
<script src="/js/angular.min.js"></script>
</html>
这是一个工作 fiddle :http://jsfiddle.net/d1c22529/
关于angularjs - 将 Angular 与 Grails 一起使用时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30858446/