I'm trying to hook up the video.js
library into my app. On one part of the app, users have the ability to upload files which may contain videos, so when output, I am using an ng-repeat
to loop through the video uploads, and output an HTML5
video tag. I now want to attach a directive to the video tag so that video.js
can be used with it.
My video output is defined as
<video ng-src="{{video.url}}" ng-repeat="video in post.attachments.video" type="{{video.mimetype}}" controls preload="metadata" id="video_{{video.id}}" video>
For my video
directive, I essentially just want to run the videojs
function to set it up, so I want to call
videojs(attrs.id, {
controls: true,
preload: "metadata",
techOrder: ["flash"]
}, function() {});
This is being called, but the issue I'm having is that the ng-repeat
hasn't finished everything yet when this directive is called, such that the attrs.id
is still video_{{video.id}}
rather than something like video_23
which I want.
How can I wait until the ng-repeat
has finished its thing before my video directive runs so I know I can use the ID attribute?
I'm currently using Angular 1.1.4.
Right now, my directive has
app.directive("video", function($parse) {
"use strict";
return {
restrict: "A",
link: function(scope, elm, attrs) {
videojs(attrs.id, {
controls: true,
preload: "metadata",
techOrder: ["flash"]
}, function() {});
}
};
});