1

I have read about passing a templateRef inside a component and then use it to render the template passed by the client being wrapped by something defined in your component.

What I need to achieve is a little more complicated.

My situation is the following: I'm building a table component that receives the array of items to be displayed along with a callback that retrieves the text from the model.

It works nicely, but I can only put text inside the table.

I'm trying to find something that works like a react render callback, where you can specify how to render each element received as parameter in the callback. But for what I've read, this is not possible in angular.

What I would like to achieve is the ability to pass the component a template that will be filled internally with the data.

Let's say for example that I want to show an image in the first column, I will pass a template that contains an image, and the src field of this image will be set inside the component accordingly to what's saved in each element of the array passed.

Is there anyway to achieve that in Angular?

Luca Pasini
  • 141
  • 8

2 Answers2

0

Directly assigning the html tags would not work in case of Angular, but you can use html sanitizer for angular to render them on screen You can use https://angular.io/api/platform-browser/DomSanitizer

For more details you can refer this angular official documentation

Nikhil Dhawan
  • 69
  • 1
  • 6
0

I found what i was looking for... See this post

Luca Pasini
  • 141
  • 8