0
jimchristian created
The standard Web project has a file /app/main/filters/moment_filter.js with the "momentFromNow" filter. How do I add another filter to format dates in another way? I tried this to add a second filter like this:
angular.module('app')
.filter('momentFromNow', function () {
return function (input) {
return moment(input).fromNow();
};
})
.filter('momentFromNow2', function () {
return function (input) {
return moment(input).fromNow();
};
});
The project builds but I get an error at runtime:
angular.js:13236Error: [$injector:unpr] http://errors.angularjs.org/1.5.0/$injector/unpr?p0=momentFromNow2FilterProvider%20%3C-%20momentFromNow2Filter
It looks like I need to register my new filter, but where? Or am I using the wrong syntax to create a filter?
2 Answer(s)
-
0
You are creating it in the right way. Probably your browser cached it. Disable caching of your browser while developing your project. Also, this is Angular topic and you can find more info on filters on the web.
-
0
Thanks - you were right, clearing the browser cache fixed the problem. I should have thought of that.