I have a video element, and I need to hide/show some elements when it is playing or in pause. This is part of the code, which should be enough for understanding:
var videoElement = angular.element('.onboardinghome-view__video video');
var vm = this;
vm.playVideo = playVideo;
vm.hideQuickSetup = false;
vm.hideVideoCaption = false;
vm.hidePlayButton = true;
videoElement.on('canplay',function() {
vm.hidePlayButton = false;
});
videoElement.on('pause',function() {
vm.hideVideoCaption = false;
});
function playVideo() {
vm.hideVideoCaption = true;
videoElement[0].play();
}
HTML:
<header id="#">
<div class="grid grid__col-6">
<div ng-hide="vm.hideVideoCaption">
<h5>The time has come. Deloitte's new improved expense tool is here.</h5>
<h4>Submitting expenses, easy as 1-2-3-4</h4>
<div class="onboardinghome-view__play-button" ng-click="vm.playVideo()"></div>
<div>GET STARTED</div>
<div><p><a href="#onboarding_setup_preferences">Setup preferences for faster expense submission</a> - <a href="#onboarding_easy_expense">Easier expense entry</a> - <a href="#onboarding_learn_new_dte">Learn about the new DTE</a></p></div>
</div>
<div class="grid__col-12 onboardinghome-view__video">
<video controls>
<source ng-src="images/dte_video.mp4" type="video/mp4">
</video>
</div>
</div>
</header>
The events are being correctly triggered, but it seems the $scope, in this case the vm element, is not updating, thus, not showing again the elements. Any idea?