在我的 AngularJS node.js 中 app基于 angular-express-blog和 express-coffee我在 Controller pic 之前的防御 angular.module
有问题:
Uncaught ReferenceError: IndexCtrl is not defined
包含模块的顺序与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')
更改订单后:
!= js('controllers')
!= js('app')
!= js('directives')
!= js('filters')
!= js('services')
错误相同。只有当我在 angular.module("myApp"...
defenition 之前将 Controller 替换为 app.coffee 时,它才有效。我当然重新启动了服务器。
更新:app file , controller file和 layout
最佳答案
在 Coffeescript 中,编译后的东西被包裹在一个闭包中:
//controllers.js:
(function() { function MyController($scope) {} })();
现在 index.html 找不到 MyController 变量,因为它在闭包中!
改用 module.controller
语法。
angular.module('myApp').controller 'MyController', ($scope) ->
这将使您的 Controller 随处可见。
关于node.js - 找不到 AngularJS Express 咖啡 Assets Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11830370/