If Angular does not load a file with ng-include ...

2015-07-01 | #angular, #solution, #webdev

This is one of those traps everyone steps in i guess. Say you wrote

<ng-include src="/templates/foobar.html"></ng-include>

This will not work. And if you think about it for a second you'll immediately see why this is. The thing in the src is an angular expression and I guess you don't have a scope var named "/template/...". So this is of course undefined. So how do you use a string here without the need to define something in the scope for this. Well, as always when you need a string: use quotes. Single quotes in this case. Inside the src double quotes.

<ng-include src="'/templates/foobar.html'"></ng-include>

And you're done.