Using ngFor within <template> causes app to crash

316 views Asked by At

I'm working on a angular2 app (version 2.4.1) and I'm trying to write a component that should take the template to be rendered from the user of the component (what was called transclusion in angular1 I believe).

I've written a component that uses [ngTemplateOutlet] to render a given template, however when passing it a template that uses ngFor it crashes because it tries to render the ngFor-content even though the array is null.

See the following plunker, which reproduces the issue: https://plnkr.co/edit/E5Nj73ElOFGDRAdpBcGf?p=preview

The first ngFor renders correctly, but when the component test-template tries to render the template it is given it fails on:

inline template:10:43 caused by: Cannot read property 'value' of undefined

Any help with this issue would be much appreciated!

EDIT: The same code works with Angular2 v2.1.2 https://plnkr.co/edit/0OyPqtvkDgTUPpwovZMc

0

There are 0 answers