我有一个表,其中每个表格单元格是一个组件的不同实例.根据数据(日期,文本,链接),我使用不同的组件.
由于这些组件有很多共同之处,我引入了一个TableCellMasterComponent,它由所有其他类型的表格单元扩展.
我的所有组件都具有相同的主机属性:
@Component({
selector: 'td[app-text-col]',
templateUrl: './text-col.component.html',
styleUrls: ['./text-col.component.css'],
host: {
"[hidden]": "col.deactivated"
},
changeDetection: ChangeDetectionStrategy.OnPush
})
export class TextColComponent extends TableCellMasterComponent{
}
Run Code Online (Sandbox Code Playgroud)
是否有可能以某种方式将其移动到TableCellMasterComponent?
我也很想给他们所有人一个上下文菜单.但正如我所看到的,无法在Master中添加HTML.真的吗?
我可以将changeDetection移动到Master吗?
我有一个在工具提示中显示一些附加数据的组件。此工具提示将在悬停时显示。
我想测试该工具提示中的数据是否正确,但我要么无法创建悬停事件,要么工具提示在我能够检查它之前就消失了。
it('has correct tooltip data', () => {
const div = fixture.debugElement.nativeElement.querySelector('div');
div.dispatchEvent(new MouseEvent('mouseover'), {
view: window,
bubbles: true,
cancelable: true
});
fixture.detectChanges();
const tooltip = fixture.debugElement.nativeElement.querySelector('ngb-tooltip-window');
});
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?有没有我可以从中汲取灵感的代码示例?
如果我在浏览器中运行测试,悬停事件将正常工作。(即使使用隔离组件)