简体   繁体   English

Angular 1.5组件流星中的LazyLoad模块

[英]LazyLoad Module in Angular 1.5 component Meteor

I am dying here on lazily loading modules into angular-meteor 1.5. 我在这里死于将模块延迟加载到流星1.5中。 So the Meteor Version is 1.4.2.3, meaning with ES2015, import, ui-router etc. So far I've tried ocLazyLoad, angularAMD has a completely different syntax (with define(function()...) which I don't know how to "merge" with the Boilerplate App of Urigo's angular-meteor. So in ocLazyLoad, I went by this https://github.com/alo/oclazyload-uirouter-component-routing-tests github example, since it is the only one I've found that has the ng 1.5 components and submodules instead of just lazily adding controllers to the main apps module. 因此,Meteor版本是1.4.2.3,这意味着使用ES2015,import,ui-router等。到目前为止,我已经尝试了ocLazyLoad,angularAMD具有完全不同的语法(带有define(function()...),我没有知道如何与Urigo的角流星的Boilerplate应用“合并”,因此在ocLazyLoad中,我通过以下https://github.com/alo/oclazyload-uirouter-component-routing-tests github示例进行了分析,因为它是我发现只有一个具有ng 1.5组件和子模块,而不是仅将控制器懒惰地添加到主应用程序模块中。

When I try to implement this, ocLazyLoad logs that the js-file is loaded, but in the Sources-tab instead of the actual file, the js-file contains the whole meteor app. 当我尝试实现此功能时,ocLazyLoad记录了js文件已加载,但是在Sources-tab中而不是实际文件中,js文件包含整个流星应用程序。

Any idea on why that is or whether angularAMD works with angular-meteor or in general, how to make lazyLoading modules work? 关于为什么这样的想法,或者angularAMD是否可以与angular-meteor一起使用,或者总的来说,如何使lazyLoading模块起作用?

It's not as natural as it should be because meteor doesn't support lazy loading yet. 它不自然,因为流星尚不支持延迟加载。 But here is a working solution: 但是这是一个可行的解决方案:

If your are trying to use lazy loading on routes like this: 如果您尝试在这样的路由上使用延迟加载:

{ path: "myPath", loadChildren: "app/myModule/myModule.module#MyModule"}

You should use instead a callback to get the module using ES5 callbacks. 您应该改用回调来使用ES5回调获取模块。

{path: "myPath", loadChildren: ()=> require('./myModule/myModule.module')["MyModule"] }

Hopefully will work for you as well. 希望也能为您服务。 :) :)

Question answered on my post 我的帖子已回答问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM