Reputation: 7704
I am building a service to handle modal windows in my Angular application, so there is a bit of manual work with linking a template, scope and controller.
I'm using $compile like so, to build the template and attach to the scope, for example:
$compile('<h1>This is my window</h1><img src="{{ imageUrl }}">')($scope);
Everything is working fine, but... the browser tries to load anything such as an image before the HTML string has even been evaluated for Angular expressions. For example, in this case, the browser tries to literally load "http://myhost.com/{{ imageUrl }}", and then immediately afterwards will load the correct URL as the Angular expression is picked up.
This happens immediately upon the $compile()($scope) is called, without even attaching/inserting the returned template to the DOM.
Basically the browser seems to be parsing the HTML before Angular replaces the Angular expressions - any kind of remote content in the HTML at all will be requested by the browser. How is this so?
Upvotes: 2
Views: 686