I'd like to write HTML similar to:
<a href="sharedasset: img.png">test</a>
<img src="sharedasset: img.png"/>
And have a directive called "sharedasset" that gets the full path to img.png
and sets the value of the attribute without the directive having any knowledge of what the attribute name is ahead of time. Is this possible?
Update
Since I originally posted this there have been some improvements to Angular and I thought I'd share what I do now as a result. In the HTML I use Guido Bouman's answer which is to create a filter and, now with Angular's bind once feature, this makes it the best option in my opinion.
In the JS code though, instead of injecting $filter
and my globalVars
constant everywhere, now I just prepend the word static
to any path of an asset that is hosted on the static content server like {templateUrl: "static/someTemplate.html"}
and then use an Angular HTTP Interceptor to look for any path that begins with "static" and replace it with the domain for the static server. Very simple.