I have an AngularJS directive:
myApp.directive('movie', function(){
return {
restrict: 'E',
replace: true,
scope: { product:'=', codebase: '@' },
template: '<object style="width:550px;height:320px;" name="movie" id="movie" codebase="{{codebase}}"' +
' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" tabindex="-1">' +
'<param value="{{product.flashURL}}" name="movie">' +
'<param value="true" name="play">' +
'<param value="true" name="menu">' +
'<param value="transparent" name="wmode">' +
'<param value="noscale" name="scale">' +
'<embed wmode="transparent" style="width:550px;height:320px;" src="{{product.flashURL}}" scale="noscale"' +
' pluginspage="http://www.macromedia.com/go/getflashplayer" play="true" name="movieEmbed" menu="true" id="movieEmbed">' +
'</object>'
};});
It is used like this:
<movie product="productInScope" codebase="http://flashcodebase..." />
I made this directive to fix the problem I was having by simply including this HTML in a view, which is this: the instant the object tag is rendered, the Flash attempts to load a movie at the URL "{{product.flashURL}}". That obviously fails, and by the time Angular gets around to interpolating the expression, it's too late.
Unfortunately, restructuring it as a directive didn't help the problem. Interestingly, the {{codebase}} expression seems to always work; maybe it evaluates first, causing the Flash to load and attempt to fetch the URL?
How would you rewrite this directive (or use some simpler approach) so that the object tag is not created until the flashURL is available?