Here's my scenario. Users enter content via tinyMCE editor, and I display this content to the user in a component like so:
@Component({
template: '
<h3>Description</h3>
<div [innerHTML]="content"></div>
'
})
export class DetailsComponent implements OnInit {
content: string = "";
constructor(private service: any){}
ngOnInit(){
this.service.loadDetails().pipe(
tap((result) => this.content = result)
).subscribe();
}
}
Now the content from the server can be anything. So if the server returns this content:
<p>This is my content from the server. <img src="..." /></p>
Then my DetailsComponent output would look like this:
<h3>Description</h3>
<div>
<p>This is my content from the server. <img src="..." /></p>
</div>
I want to write a component to replace any images with a custom component. How do you do this without using an existing #template reference?
Essential, it could look like this where my custom component wraps the image:
<h3>Description</h3>
<div>
<p>This is my content from the server. <custom-component><img src="..." /></custom-component></p>
</div>