Hello everybody.

I have a simple multiple-answer quiz. The questions and answer options come 
from a JSON array. There is an .MP3 clip for each question, but its 
filename is not in the array. I just set the path to the media directory 
and increment the filename depending on the question number – 
question_1.mp3, question_2.mp3 and so on. So far so good.

I have reduced the HTML5 standard player chrome to a single "Play' button. 
It has the onclick event that should look like this
<button onclick="document.getElementById('player-0').play()">Play the Audio
</button> (reference) 
<https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_HTML5_audio_and_video>

My whole markup looks like this:

<audio id="player-{{$index}}" src="{{'media/question_' + ($index+1) + 
'.mp3'}}" type="audio/mpeg"></audio> 
<div class="btn" onclick="{{'document.getElementById(\'player-'+$index+
'\').play()'}}" >Play</div>

where $index is the question's index in the array.

Here's the problem:
The substitution happens fine within the <audio> tags, but not for onclick. 
This is what I get:

<audio id="player-0" src="media/question_1.mp3" type="audio/mpeg"></audio>
<div class="btn" 
onclick="{{'document.getElementById(\'player-'+$index+'\').play() 
'}}">Play</div>

What am I missing?

-- 
You received this message because you are subscribed to the Google Groups 
"Angular" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to