I'm not exactly sure what to call this so I might have missed some things in my search for an answer for this but basically I have data that comes in from an external api and it gets inserted into an innerHTML
tag now in the data that is being returned is some html which then gets processed thanks to innerHTML
but I have certain keywords in the returned html like this [username]
and I want to replace that with data I have stored. So in my .ts file I might have..
username: 'name';
then in my html I have
<div class='inner-html' [innerHTML]="data.html"></div>
and in my response from data.html
the html is like so
<h1>Hey [userName] lorem ipsum...</h1>
so I want to replace the [userName]
that comes in dynamically from the external api with the username that is stored in username
I tried to put {{username}}
in the html that is coming in.. but that didnt work and I also tried ${username}
but that also didnt work..
Im wondering if there is another way?
EDIT Ive tried to use str.replace(); in the onChanges life cycle event but that isn't working either my code is ..
const html = <HTMLElement>document.querySelector('.inner-html');
html.innerHTML.replace('[userName]', this.username);
Now something like this must be possible, any help would be appreciated
Thanks