问题描述
在我的AngularJS node.js中, app 基于 angular-express-blog 和速溶咖啡我在管制员angular.module方面遇到问题" rel =" nofollow noreferrer>图片:
In my AngularJS 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')
更改顺序后:
!= js('controllers')
!= js('app')
!= js('directives')
!= js('filters')
!= js('services')
错误相同.它仅在我在angular.module("myApp"...
定义之前将控制器替换为app.coffee时起作用.我当然重启了服务器.
Error the same. It works only when I replace controllers to app.coffee before angular.module("myApp"...
defenition. I restarted server of course.
推荐答案
在Coffeescript中,已编译的内容包装在一个闭包中:
In Coffeescript, compiled things are wrapped in a closure:
//controllers.js:
(function() { function MyController($scope) {} })();
现在index.html找不到MyController变量,因为它处于关闭状态!
Now index.html can't find the MyController variable because it's in a closure!
改为使用module.controller
语法.
angular.module('myApp').controller 'MyController', ($scope) ->
这将使您的控制器在任何地方都可见.
This will cause your controller to be visible everywhere.
这篇关于找不到AngularJS Express咖啡资产控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!