Reputation: 747
I've created a custom filter. However when I call this filter in my html, I get the error Unknown provider: fixUrlFilterProvider <- fixUrlFilter
Filter Code:
angular.module('TestDemo')
.filter('fixUrl',
function () {
'use strict';
return function (relativePath) {
return 'http://test/' + relativePath;
};
}
);
HTML
<a data-ng-href="{{'Login.aspx' | fixUrl}}" login </a>
Kindly let me know how I can fix this. Thanks in advance.
Upvotes: 0
Views: 265
Reputation: 5870
I received this error when I accidentally defined the filter in my controller function instead of after declaring my module. Please make sure that after you have created your todoApp, that directly after, you create custom filter
//todoApp is an AngularJS module object
var todoApp = angular.module("todoApp", []);
//Adding custom filter to demonstrate results
todoApp.filter("checkedItems", function () {
return function (items, showComplete) {
var resultArr = [];
angular.forEach(items, function (item) {
if (item.done == false || showComplete == true) {
resultArr.push(item);
}
});
return resultArr;
}
});
Upvotes: 0
Reputation: 180
Usually happens to me when I have forgotten to include the js file.
If the above steps don't help post the index.html, and JS files
Upvotes: 1
Reputation: 2405
Make sure your app is really called "TestDemo", that your html in enclosed inside the "TestDemo" app and that you have this file included in your script tags
Upvotes: 0