In my angular node.js app based on angular-express-blog and express-coffee I have an issue with defenition angular.module
before controllers pic:
Uncaught ReferenceError: IndexCtrl is not defined
The order of including modules the same as in angular-seed:
// JS
!= js('lib/jquery-1.7.2.min.js')
!= js('lib/bootstrap.min.js')
!= js('lib/angular.min.js')
!= js('app')
!= js('controllers')
!= js('directives')
!= js('filters')
!= js('services')
After change order to this:
!= js('controllers')
!= js('app')
!= js('directives')
!= js('filters')
!= js('services')
Error the same. It works only when I replace controllers to app.coffee before angular.module("myApp"...
defenition. I restarted server of course.
Update: app file, controller file and layout
In Coffeescript, compiled things are wrapped in a closure:
//controllers.js:
(function() { function MyController($scope) {} })();
Now index.html can't find the MyController variable because it's in a closure!
Use the module.controller
syntax instead.
angular.module('myApp').controller 'MyController', ($scope) ->
This will cause your controller to be visible everywhere.