首页 > 解决方案 > 使用 angular-meteor 在 Angular 中延迟加载不可路由的模块

问题描述

我按照本教程https://netbasal.com/the-need-for-speed-lazy-load-non-routeable-modules-in-angular-30c8f1c33093加载了一个不可路由的模块。

但是指示 Angular 要求 Webpack 为我们的模块创建一个单独的块以便我们稍后可以在 angular.json 中延迟加载它的步骤无法实现它,因为我正在使用 MeteorCLI,如下面的 Urigo / angular-meteor https示例://github.com/Urigo/angular-meteor/tree/master/examples/MeteorCLI/all-in-one

尝试通过 load-module.directive.ts 加载模块时出现的错误是:

错误参考错误:系统未定义

at SystemJsNgModuleLoader.loadAndCompile (modules.js?hash=9d3d781b9164d8358322d2f1c42fce556c401bbc:42359)
at SystemJsNgModuleLoader.load (modules.js?hash=9d3d781b9164d8358322d2f1c42fce556c401bbc:42351)
at LoadModuleDirective.ngOnInit (load-module.directive.ts:48)
at checkAndUpdateDirectiveInline (modules.js?hash=9d3d781b9164d8358322d2f1c42fce556c401bbc:46075)
at checkAndUpdateNodeInline (modules.js?hash=9d3d781b9164d8358322d2f1c42fce556c401bbc:47339)
at checkAndUpdateNode (modules.js?hash=9d3d781b9164d8358322d2f1c42fce556c401bbc:47301)
at debugCheckAndUpdateNode (modules.js?hash=9d3d781b9164d8358322d2f1c42fce556c401bbc:47935)
at debugCheckDirectivesFn (modules.js?hash=9d3d781b9164d8358322d2f1c42fce556c401bbc:47895)
at Object.eval [as updateDirectives] (provider-details.component.html:296)
at Object.debugUpdateDirectives [as updateDirectives] (modules.js?hash=9d3d781b9164d8358322d2f1c42fce556c401bbc:47887)

技术规格:

有人可以告诉我如何在 angular-meteor 中实现延迟加载不可路由的模块

标签: angularmeteorlazy-loadingangular-meteor

解决方案


看看https://github.com/wishtack/wishtack-steroids/tree/master/packages/reactive-component-loader

这允许您在不需要路线的情况下加载角度模块。它并不完美或简单,但它可以帮助您入门。

尝试在我的构建中使用 aot 进行编译存在一些问题,我不得不稍微编辑它以使其工作,但这可能只是我做错了。


推荐阅读