I am designing a game, and I am dynamically creating statements with blanks inside and ask the players to fill in the blanks. I need string interpolation to record user's input, but I also need to set dynamic innerHTML because the blanks can be anywhere in the statement.
I know this sounds vague, here is relevant code examples:
app.component.html
<input type="range" step="1" min="0" max="100" class="slider
(input)="sliderMoved($event)">
<div class="question" [innerHTML]="questionStatement"></div>
app.component.ts
display=50;
questionStatement='<div class="percent">{{display}}%</div>
of Americans have a university degree.'
questionStatementExample2='Canada is <div class="percent">{{display}}%</div>
the size of America.'
sliderMoved(event: any) {this.display=event.target.value;}
The questionStatement can have <div class="percent">{{display}}%</div> in anywhere in the sentence, hence the need of dynamic entry point.
Here, string interpolation ({{display}}) does not work in innerHTML. It will show up on screen literally as {{display}}. What can I do in this case?