Directive
myApp.directive('vlcControls', function ($compile, $rootScope, $timeout, $window, pictureboxConstants) {
var linker = function (scope, element, attrs) {
vlcPlayerCustomTemplate = 'some html goes here';
scope.getVLC = function (name) {
if ($window.document[name]) {
return $window.document[name];
}
if ($window.navigator.appName.indexOf("Microsoft Internet") == -1) {
if ($window.document.embeds && $window.document.embeds[name])
return $window.document.embeds[name];
} else {
return $window.document.getElementById(name);
}
}
scope.doPlayPause = function (vlcPlayer, event) {
var vlc = scope.getVLC(vlcPlayer);
if (vlc) {
if (vlc.playlist.isPlaying) {
vlc.playlist.pause();
angular.element(event.target).children().removeClass('fa fa-pause font-12');
angular.element(event.target).children().addClass('fa fa-play font-12');
} else {
if (vlc.audio.mute == true) {
//do something
}
vlc.playlist.play();
}
}
}
angular.element(document.querySelector("#controls" + index)).append(element.html(vlcPlayerCustomTemplate));
$compile(element.contents())(scope);
};
return {
restrict: "E",
link: linker
};
});
Controller
myModule.controller('myModuleCtrl', function ($scope, $http, $controller, $compile) {
$compile("<vlc-controls></vlc-controls>")($rootScope);
});
What is the best way to only call specific directive
function/method doPlayPause
from controller
without using vlcPlayerCustomTemplate
html elements or any DOM
manipulations ?