Reputation: 1569
Trying to convert working JS to coffee script in my angular app but its raises Error: [ng:areq] Argument 'ContactController' is not a function, got undefined
Here is my code.
angular.module("app", [
"ngResource"
"ngRoute"
]).run ($rootScope) ->
$rootScope.log = (thing) ->
console.log thing
The following js works fine
angular.module("app", ["ngResource", "ngRoute"]).run(function($rootScope) {
$rootScope.log = function(thing) {
console.log(thing);
};
});
Upvotes: 1
Views: 201
Reputation: 46613
Your indents are off. Coffeescript is whitespace aware.
angular.module("app", [
"ngResource"
"ngRoute"
]).run ($rootScope) ->
$rootScope.log = (thing) ->
console.log thing
Becomes:
angular.module("app", [ "ngResource", "ngRoute" ]).run ($rootScope) ->
$rootScope.log = (thing) ->
console.log thing
This doesn't explain why ContactController
wouldn't be loading, but if your module isn't being defined correctly that could explain it.
Upvotes: 1
Reputation: 417
angular.module("app", [
"ngResource"
"ngRoute"
]).run ($rootScope) ->
You missed a comma here..
angular.module("app", [
"ngResource",
"ngRoute"
]).run ($rootScope) ->
Upvotes: 0