Hikaru Shindo
Hikaru Shindo

Reputation: 2913

Error when using angular with Grails

Here is my 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>

When I build an app, There is an error like this,

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

Upvotes: 0

Views: 137

Answers (1)

Abdel Raoof Olakara
Abdel Raoof Olakara

Reputation: 19353

The error that you get says:

Failed to instantiate module myApp due to: {1}

Which basically means angular could not create an instance of myApp. You might want at a minimum level to have this code:

var myApp = angular.module('myApp',[]);

function MyCtrl($scope) {

}

and in your 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>

Here is a working fiddle: http://jsfiddle.net/d1c22529/

Upvotes: 1

Related Questions