找不到AngularJS Express咖啡资产控制器 [英] AngularJS express coffee-assets controller not found

查看:65
本文介绍了找不到AngularJS Express咖啡资产控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的AngularJS node.js中, app 基于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咖啡资产控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆