jeudi 2 août 2018

angular 6 create instance of TemplateRef

I have (angular 6) component and input parameter of TemplateRef<any> type

class TestComponent {
    @Input() tpl: TemplateRef<any>;
    ...
}

Now I want to create a test and I can't find the way how to create a template in test and set it as an input field.

In my HTML I have template like

<test>
    <ng-template #tpl>
        <div>OLOLO</div>
    </ng-template>
</test>

I need something like this

fixture = TestBed.createComponent(TestComponent);
component = fixture.componentInstance;
component.template = here I need instance of TemplateRef

Thanks

Aucun commentaire:

Enregistrer un commentaire