I'm trying to split my controllers into multiple files, but when i try to register them at my module im getting an error:
groupcontroller.coffee
app = angular.module('WebChat', []);
app.controller 'GroupController', ($scope) ->
usercontroller.coffee
app = angular.module('WebChat', []);
app.controller 'UserController', ($scope) ->
Error
Error: Argument 'GroupController' is not a function, got undefined
From the documentation I dont really get what the module method does anyway. Does it store my controller with the key 'Webchat'?
Edit:
It also seems that passing [] creates a new module and overwrites the previous one
app = angular.module('WebChat', []);
To prevent this, you have to leave out the [] like
app = angular.module('WebChat');
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…