前角preSS咖啡资产控制器未找到 [英] Angular express coffee-assets controller not found
问题描述
在我的角度Node.js的应用基础上的角前preSS-博客和的前preSS-咖啡我有defenition问题 angular.module
控制器之前 PIC :
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')
在变化,以这样的:
!= js('controllers')
!= js('app')
!= js('directives')
!= js('filters')
!= js('services')
错误一样。当我更换控制器之前来app.coffee angular.module(对myApp...
defenition。我当然重新启动服务器它才有效。
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.
这篇关于前角preSS咖啡资产控制器未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!