我的角的应用程序的结构是这样的:
My Angular app structure is like this:
App.js
angular.module('RateRequestApp', [
'RateRequestApp.services',
'RateRequestApp.controllers',
'ui.bootstrap',
'angular-loading-bar',
'textAngular',
'angularFileUpload'
]);
我使用不同的页面不同的HTML文件,我不使用角的 $路线
,但我仍然想在不同的控制器上的所有页面中使用相同的应用程序。
I am using different HTML files for different pages and I am not using
Angular's $route
, but still I want to use same app in all pages with different controllers.
正如你可以看到我注入第三方模块到我的应用程序。问题是,在一些网页我不希望一些这方面的模块,我怎样才能避免他们在哪里我也不需要他们?
As you can see I am injecting third party modules to my app. The problem is that in some pages I don't want some of this modules, How can I avoid them where I don't need them?
是的,你可以做到这一点是这样的:
Yes you can do it something like this:
var myApp = angular.module('RateRequestApp', [
'RateRequestApp.services',
'RateRequestApp.controllers',
'ui.bootstrap',
'angular-loading-bar'
]);
var lazyModules = ['textAngular', 'angularFileUpload'];
angular.forEach(lazyModules, function(dependency) {
myApp.requires.push(dependency);
});
在此情况下,您可以有条件地注入模块。 (但请注意,某些模块的延迟加载可能无法正常工作哪里有需要进行一些配置。)
In this case you may inject the modules conditionally. (But please note, lazy loading of some module may not work where there is some configuration needed.)
上一篇:UI的选择错误"不能插值:{{$ select.getPlaceholder()}}"错误、插值、UI、QUOT
下一篇:MixedContent当我加载HTTPS网页,通过AJAX,但浏览器仍然认为它是HTTP当我、它是、加载、浏览器