视频加载事件的角度 [英] Angular on video load event

查看:20
本文介绍了视频加载事件的角度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仍在尝试理解角度...

I'm still trying to understand angular...

基本上,我有一个 html5 视频,我想收听 onloadeddata 事件 (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');
});

但它也不起作用...

推荐答案

想通了!看起来我需要使用:

Figured it out! Looks like I need to use:

$element[0].addEventListener(...)

代替:

$element.addEventListener(...)

这篇关于视频加载事件的角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆