Indeed, it is possible to design your own unique filters, such as:
angular.module('', [])
.filter('customFilter', function() {
return function(input,param1) {
...
Utilizing this filter in your HTML is as simple as using any other filter, like {{somevalue | customFilter}}
When dealing with date-related issues, it's worth mentioning that you can also call filters directly from your code by injecting the $filter
service. This way, you can extract various values from the filter, for instance:
var filteredDate = $filter('date')(new Date(input), 'dd MMMM');
Combining all of the above, it seems like the most appropriate approach to implement the custom filter would be:
angular.module('', [])
.filter('customFilter', function($filter) {
return function(input) {
var filteredYearMonth = $filter('date')(new Date(input), 'MMMM yyyy');
var filteredDay = (new Date(input)).getDay();
var arr = ['st', 'nd', 'rd']
var myDate = arr[filteredDay] || "th" + filteredYearMonth;
return myDate
...