You can enter $ filter as a dependency, as you would for a controller, service, or directive.
myApp.filter('myFilter',[ '$filter', function ($filter) { return function (input) { return $filter('date')(myDate,myFormat); } }]);
On a side note, you should use angular.isDefined instead of != undefined .
See the $ filter and date documentation for more details.
source share