Mik*_*e M 5 karma-jasmine angular-components angular
我有一个带有模板的组件,可以像这样有条件地显示:
@Component({
selector: "presentation",
template: "<template #tpl><!-- HTML --></template>"
})
export class Presentation implements AfterViewInit {
@ViewChild('tpl') template: TemplateRef<any>;
constructor(private view: ViewContainerRef) {}
ngAfterViewInit() {
this.view.createEmbeddedView(this.template);
}
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试编写测试,但一旦我打电话
it("should launch card in practice mode", () => {
fixture.detectChanges();
}
Run Code Online (Sandbox Code Playgroud)
我得到:
Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?