home.html
<videodata></videodata>
videoctrl.js
$rootScope.cameraRTSPUrl = obj.objUrl;
directive.js
directive - myApp.directive('videodata', function() {
return {
restrict: 'EA',
scope : true ,
link: function(scope, element, attrs) {
element.replaceWith('<object classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921" '+
'codebase="http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab" '+
'id="vlc" events="True"> '+
'<embed id="123" type="application/x-google-vlc-plugin" version="VideoLAN.VLCPlugin.2" autoplay="yes" '+
'loop="no" width="800" height="600" target="'+scope.cameraRTSPUrl+'"> '+
'</object>');
}
};
});
The above code works and rendered HTML is below
<object events="True" id="vlc"
codebase="http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab"
classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921">
<embed width="800" height="600" target="rtsp://localhost/media/media.amp" loop="no" autoplay="yes"
version="VideoLAN.VLCPlugin.2" type="application/x-google-vlc-plugin" id="123">
</object>
- The code works with
element.replaceWithbut is this the correct way to replace HTML using custom directive ? - How do I use
transclude: true,property in order to replace my HTML ?
P.S. I am using scope.cameraRTSPUrl value inside link function.
replace : trueand usetemplate : <your html>in return object. That might help. Sorry, but I did not get what you want to achieve. In order to transcendent inner html of the directive, you also need to settransclude:trueand useng-transcludedirective in your template. docs.angularjs.org/api/ng/directive/ngTransclude