Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 在模块中动态声明(注册)一个组件(当该组件在9中延迟加载时)_Angular_Angular9 - Fatal编程技术网

Angular 在模块中动态声明(注册)一个组件(当该组件在9中延迟加载时)

Angular 在模块中动态声明(注册)一个组件(当该组件在9中延迟加载时),angular,angular9,Angular,Angular9,当特定(xyz)模块中的组件在Angular 9中延迟加载时,是否有方法动态声明(注册)该组件 组件未在任何模块中声明(注册),并且在执行以下操作时,它被创建为独立组件:- this.viewContainerRef.clear(); const SomeComponent = this.componentFactoryResolver.resolveComponentFactory("./project/some-component-path"); this.co

当特定(xyz)模块中的组件在Angular 9中延迟加载时,是否有方法动态声明(注册)该组件

组件未在任何模块中声明(注册),并且在执行以下操作时,它被创建为独立组件:-

 this.viewContainerRef.clear();

 const SomeComponent = this.componentFactoryResolver.resolveComponentFactory("./project/some-component-path");

 this.componentRef  =this.viewContainerRef.createComponent(SomeComponent);

我想知道,当组件被延迟加载时,是否有一种方法可以在运行时在特定模块中动态注册该组件。因此,我的组件将能够使用该特定(xyz)模块中导入的所有模块。

为什么不直接将组件声明为模块的一部分?这应该具有您使用angular9时所期望的效果,您可以延迟加载组件。选中此项: