Is there a way I can pass variables to templates in Angular2?
Let\'s say I have the following code:
But this doesn't work if the template is located in another component. How do you pass a context object in such scenario?
I added
@Input() itemTemplate: TemplateRef
in component where I will use it, and in template of this component I write something like this:
Code of template from outside component:
Hello, {{data.name}}
Just pass link to dataRendererTpl as @Input() property to component in which you need it