我正在Angular 2应用程序上工作,需要传递类型的通用组件,以便在处理完我想要的数据后最终确定;
this.myCollection = [
{ path: 'myPath', component: SurveyFormComponent },
{ path: 'yourPath', component: SurveyFormComponent },
]
我已经定义了通用数据类型的类
export class DynamicRouteDataModel<T>{
path:string;
component: T;
constructor(path:string){
this.path = path
}
}
private routeObject: DynamicRouteDataModel<SurveyFormComponent>;
private assembleDynamicRoutes(){
this.dynamicRoutesData.forEach(routeItem => {
this.routeObject = new DynamicRouteDataModel<SurveyFormComponent>(routeItem.routeURL);
//this.dynamicRoutes.push({"path":routeItem.Rout })
});
}
我的问题是,当创建DynamicRouteDataModel实例时,我无法确定如何传递typeof组件的路径