我正在尝试设置一个标签系统,允许组件自己注册(带标题).第一个选项卡就像一个收件箱,有大量的操作/链接项可供用户选择,每个点击都应该能够在点击时实例化一个新组件.动作/链接来自JSON.
然后,实例化的组件将自己注册为新选项卡.
我不确定这是否是"最佳"方法?Sofar我见过的唯一指南是静态标签,这没有帮助.
到目前为止,我只有主要引导的标签服务在整个应用程序中持续存在,看起来像这样的东西.
export interface ITab { title: string; }
@Injectable()
export class TabsService {
private tabs = new Set<ITab>();
addTab(title: string): ITab {
let tab: ITab = { title };
this.tabs.add(tab);
return tab;
}
removeTab(tab: ITab) {
this.tabs.delete(tab);
}
}
Run Code Online (Sandbox Code Playgroud)
问题:
DynamicComponentBuilder会被使用吗?ng-content,但我找不到有关如何使用它的更多信息编辑:尝试澄清
将收件箱视为邮件收件箱,将项目作为JSON提取并显示多个项目.单击其中一个项目后,将创建一个新选项卡,其中包含该项操作"类型".然后类型是一个组件
Edit2:图片
我正在创建一个表单,从后端获取字段。映射后,我有这样的东西:
genericFilters: {
iboId: {
'display': false,
'template': ''
},
iboCode: {
'display': true,
'template': 'text_input_iboCode',
/*'template': 'text/iboCode'*/
},
iboName: {
'display': true,
'template': 'text_input_iboName'
},
iboSurname: {
'display': true,
'template': 'text_input_iboSurname'
},
iboRank: {
'display': false,
'template': 'multiselect_iboRank',
/*'template': 'select/multi_iboRank',*/
},
iboEmail: {
'display': false,
'template': 'text_input_iboEmail'
},
iboNewsletter: {
'display': true,
'template': 'simple_select_iboNewsletter',
/*'template': 'select/simple_iboNewsletter',*/
},
};
Run Code Online (Sandbox Code Playgroud)
我的想法是在应用程序级别为表单字段创建每个字段类型(checkbox、multiselect、text、等)。radio并使用上面的映射JSON将某种字段类型应用于从后端接收的每个字段。
在我的示例中,该字段iboId应具有字段类型<text_input_iboCode>。
所以,在我看来,我不想有这样的事情:
<text_input_iboCode></text_input_iboCode>
<text_input_iboName></text_input_iboName>
<text_input_iboSurname></text_input_iboSurname>
Run Code Online (Sandbox Code Playgroud)
我实际上想让表单创建更抽象,如下所示: …