Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.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 动态生成角度布线/加载组件_Angular_Typescript_Angular2 Routing_Angular Components - Fatal编程技术网

Angular 动态生成角度布线/加载组件

Angular 动态生成角度布线/加载组件,angular,typescript,angular2-routing,angular-components,Angular,Typescript,Angular2 Routing,Angular Components,我希望能够从连接到routes的各种动态加载组件构建Angular2(Angular2.4)模块,最好是从某种配置文件。因此,我可以使用我们库中的组件基于此配置文件启动SPA。各种组件/路线最终成为贯穿应用程序流程的线性路线 例如-config.json:-我想这可能看起来有点像路由配置 [ {path: 'signup', component: SignupComponent, importPath: './signup/signup.component'} {path: 'login', c

我希望能够从连接到routes的各种动态加载组件构建Angular2(Angular2.4)模块,最好是从某种配置文件。因此,我可以使用我们库中的组件基于此配置文件启动SPA。各种组件/路线最终成为贯穿应用程序流程的线性路线

例如-config.json:-我想这可能看起来有点像路由配置

[
{path: 'signup', component: SignupComponent, importPath: './signup/signup.component'}
{path: 'login', component: LoginComponent, importPath: './login/login.component'}
,{path: 'buyStuff', component: BuyStuffComponent, importPath: './buystuff/buystuff.component'}
]
但是,由于这将是动态生成的,因此我们有一个问题,即如果您单击“注册”中的“下一步”按钮,您将转到LoginComponent等。 同样地,无论如何包装,都可能需要包括所有可能的进口

我不确定使用路由来确定动态组件是否比尝试使用路由更好——不幸的是,文档中没有这样的示例。 我已经环顾了一下,但大多数示例似乎都使用了不推荐的功能

非常感谢您的帮助/建议

听起来像