I am trying to create a filter that will concatenate a path with an image name. I store a constant path for images in a value defined on my app like this:
app.value('config', { siteID: '29', apiRoot: 'http://localhost:54003/api', imageRoot: '/Content' });
Now in my filter I want to inject the config object and use it in my filter:
(function () {
var app = angular.module('myApp');
app.filter('imageRoot', ['config', imageRoot]);
function imageRoot(config) {
return function (imgName,config) {
return config.imageRoot + '/' + imgName; // config is undefined
};
};
})()
Called from html like this:
<img src="{{post.Icon | imageRoot}}" alt="" />