I need to dynamically change some scope variables after song in audio tag is finished. My problem is that scope.test is not affected by audio directive.
angular.module('playItApp', [])
.controller('audioController', ['$scope', function($scope){
$scope.test = 'songNotFinished';
})
.directive('audio', function(){
return {
restrict: 'E',
link: function(scope, element, attrs){
element[0].onended = function() {
scope.test = 'songFinished';
this.load();
};
}
}
});
<div ng-controller="audioController">
<h1>{{ test }}</h1>
<audio controls autoplay>
<source ng-src="{{ some_path }}" type="audio/mpeg">
</audio>
</div>