I ran into a similar problem trying to embed a PDF through a directive. The problem is that when the template is placed in the DOM, the bindings have not yet been interpolated, as @mfelix suggests. However, this is more complicated, because object calls the code outside the browser, therefore, it is not guaranteed to reproduce incorrect or dynamic attributes well (it depends on the plugin that I assume).
I had to write a link function, which is $observes variable, as in the solution ng-src / ng-href . In the case of ng-src or ng-href $observe for the variable simply sets the corresponding attribute, and everything works because HTML5 (or, as we called it, DHTML) is famously similar to this. For example, you might have a <a> tag without the corresponding href . The browser does a great job of this. And when you install href for it after the first Angular digest, the browser can handle it. But for the <object> it does not work so well, because even if the plug-in is not configured correctly (say, the src attribute is missing), the browser does not know this, and it will still refer to the corresponding plug-in, which will process the missing information in a very peculiar way. In my case, Firefox handled it gracefully and Chrome barfed.
So, the next approach I tried was to use the $observing to insert a child element containing the fully specified object tag (concatenate this line into a template line using the + operator).
A simplified definition of an example directive:
scope: ... link: function(scope, element, attrs) { attrs.$observe('src', function(value) { if (value) { element.html( '<object width="100%" type="application/pdf" data="'+value+'">'); } else { element.html("<div></div>");
When src finally matters, and when its value changes, the callback that you register through $ observ will be called.
My third solution, which I liked the most, was to process the PDF files in GIF files and display them as images, completing the overflowing damn plugins (and no, PDF.js didn't cut it). Perhaps you can turn your flash movies into animated .gifs. That would be awesome.