使用createEmbeddedView测试Angular 2组件

时间:2017-05-19 07:18:32

标签: angular karma-jasmine angular-components

我有一个模板组件,有条件地显示如下:

@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); 
    }
}

我正在尝试编写测试但是只要我打电话

it("should launch card in practice mode", () => {
    fixture.detectChanges();
}

我明白了:

Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked

我做错了什么?

0 个答案:

没有答案