正如标题中所说,我正在尝试测试 ng-template 中的输入。问题是,我无法访问输入。如果我从 ng-template 中取出输入,它可以工作,但我需要它在 ng-template 中。
emp.html 的代码来自 primefaces 文档。链接:https : //www.primefaces.org/primeng/#/table过滤部分
emp.html
<ng-template pTemplate="caption">
<div style="text-align: right">
<i class="fa fa-search" style="margin:4px 4px 0 0"></i>
<input type="text" pInputText size="50" placeholder="Global Filter"
(input)="dt.filterGlobal($event.target.value, 'contains')"
style="width:auto">
</div>
</ng-template>
Run Code Online (Sandbox Code Playgroud)
emp.component.spec.ts
describe('EmpComponent', () => {
let component: EmpComponent;
let fixture: ComponentFixture<EmpComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [SharedModule, HttpClientTestingModule],
declarations: [ EmpComponent, TestTableComponent ],
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
providers: [
{provide: EmpService, useClass: MockEmpService},
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = …Run Code Online (Sandbox Code Playgroud)