Thank you, I will give it a try. The reason I keep banging my head against this wall is because unless I code it myself, run into problems and solve problems, I will not learn. Right now all looks like it should work, but it doesn't. I suspect it has something to do with parsing order, but I just don't know enough and could use a little hint.
On Thu, Nov 24, 2016 at 9:26 PM, Sander Elias <[email protected]> wrote: > Hi Andrei, > > Why don't use a small component to enable play-on-click? > Something like: > > (function() { > 'use strict'; > angular > .module('Module') > .component('myPlayer', { > template:` > <audio src="{{'media/question_' + ($ctrl.index+1) + > '.mp3'}}" type="audio/mpeg"></audio> > <div class="btn" ng-click='$ctrl.playMe()' >Play</div> > `, > controller: ControllerController, > bindings: { > index: '=' > }, > }); > > ControllerController.inject = ['$element']; > function ControllerController($element) { > var ctrl = this; > > //////////////// > > ctrl.onInit = function() { > crtl.audioEl = $element[0].getElementsByTagName('audio') ; //get > the audo element contained in this component > }; > crtl.playMe = function () { > ctrl.audioEl.play(); > } > } > })(); > > > and use it like this in your template: > > <my-player index="$index></my-player> > > It would unclutter a lot of your code, and encapsulate the whole handling > of the audio stuff inside a single component. > > Regards > Sander > > PS, I just typed this up as an example and didn't run/try it at all!, it > might need some filling to get it running for real! ;) > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Angular" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/angular/UW4DfbJqARI/unsubscribe. > To unsubscribe from this group and all its topics, 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. > -- 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.
