我正在尝试使用valor-software/ngx-bootstrap创建动态选项卡,但我想将组件的选择器放在动态创建的选项卡内容中,
在文档示例中,我们有:
import { Component, ChangeDetectionStrategy } from '@angular/core';
@Component({
selector: 'demo-tabs-dynamic',
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './dynamic.html'
})
export class DemoTabsDynamicComponent {
tabs: any[] = [
{ title: 'Dynamic Title 1', content: 'Dynamic content 1' },
{ title: 'Dynamic Title 2', content: 'Dynamic content 2', disabled:
true },
{ title: 'Dynamic Title 3', content: 'Dynamic content 3',
removable: true }
];
addNewTab(): void {
const newTabIndex = this.tabs.length + 1;
this.tabs.push({
title: `Dynamic Title ${newTabIndex}`,
content: `Dynamic content ${newTabIndex}`,
disabled: false,
removable: true
});
}
}
我希望能够做这样的事情:
import { Component, ChangeDetectionStrategy } from '@angular/core';
@Component({
selector: 'demo-tabs-dynamic',
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './dynamic.html'
})
export class DemoTabsDynamicComponent {
tabs: any[] = [
{ title: 'Dynamic Title 1', content: 'Dynamic content 1' },
{ title: 'Dynamic Title 2', content: 'Dynamic content 2', disabled:
true },
{ title: 'Dynamic Title 3', content: 'Dynamic content 3',
removable: true }
];
addNewTab(): void {
const newTabIndex = this.tabs.length + 1;
this.tabs.push({
title: `Dynamic Title ${newTabIndex}`,
content: `<my-component></my-component>`, // Here is the change
disabled: false,
removable: true
});
}
}
Angular 将组件选择器清理为字符串 有什么解决方法吗?