角上的视频加载事件 [英] Angular on video load event
本文介绍了角上的视频加载事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我仍然在试图理解的角度...
I'm still trying to understand angular...
基本上,我有一个HTML5视频,我想听听 onloadeddata code>事件(的 http://www.w3schools.com/jsref/event_onloadeddata.asp )。
Basically, I have an html5 video and I want to listen to the onloadeddata
event (http://www.w3schools.com/jsref/event_onloadeddata.asp).
这是我有:
HTML
<video autoplay="autoplay" loaded-data loop style="display: none;">
<source src="videos/example.mp4" type="video/mp4">
<source src="videos/example.ogg" type="video/ogg">
</video>
指令:
angular.module('myApp')
.directive('loadedData', function () {
return function ($scope, $element) {
$element.addEventListener("loadeddata", function () {
console.log('test'); // never calls
});
}
});
这是处理这个正确的方式?出于某种原因,事件侦听器永远不会被调用。
Is this the correct way of handling this? For some reason, the event listener never gets called.
我也试过
$element.bind('loadedData', function () {
console.log('test');
});
,但它也不起作用...
but it also doesn't work...
推荐答案
想通了!看起来我需要使用:
Figured it out! Looks like I need to use:
$element[0].addEventListener(...)
而不是:
$element.addEventListener(...)
这篇关于角上的视频加载事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文