I have an HTML5 <video>
element in an Angular2 component. I need access to it in order to check the duration before allowing the user to share it to Twitter.
Is there any way through model binding, or direct access to the DOM, that I can get this information in the component's backing class?
I've tried binding it using ng-model, like this in the component's template:
<video controls width="250" [(ng-model)]="videoElement">
<source [src]="video" type="video/mp4" />
</video>
and in the component's class (TypeScript):
videoElement: HTMLVideoElement;
That gives me this error: EXCEPTION: No value accessor for '' in [null]
I was able to access it by just giving the video element an id and using document.getElementById("videoElementId")
but it seems like there must be a better way.