我有一个角度的应用程序,并在其中我可以看到这个咖啡app.coffee文件....将模块插入其他模块用于DI用途的角度有什么条件?
app = angular.module 'app', [
'ngRoute',
'ngResource',
'ui.router',
'app.filters',
'app.services',
'app.directives',
'app.controllers',
'app.templates',
]
angular.module('app.services', ['ngResource'])
angular.module('app.controllers',[])
angular.module('app.directives', [])
angular.module('app.filters', [])
angular.module('app.templates', [])
angular.module('app.models', [])
我真的不明白,为什么我不得不注入ngResource到应用服务模块直接AND进入应用模块。当然,我可以将所有依赖关系连接到应用程序模块,然后它将允许全局访问其余的模块?
所以我把它 angular.module('app.services',['ngResource']) line,仍然可以在我的app.services模块中访问它吗? – Exitos 2014-10-20 10:59:58
只有当另一个模块没有这种依赖性。 – 2014-10-20 11:02:50
很抱歉,如果我希望应用程序能够访问整个应用程序,那么它就会进入“应用程序”,因此我永远不需要将它放在app.services中,但是如果我想在app.services中使用它,它在那里。如果是这样的话,那么在两个地方都没有用。我可能只是在'应用'中拥有它,因为我的整个应用都需要它。是对的吗? – Exitos 2014-10-20 11:12:08