I have a filter, linkifyStuff, in which I want some variables processed using another filter. I can\'t figure out the syntax to call one filter from another.
I know
@useless asked if there was "any way to do this for default filters."
A round-about way to use default filters: pipe it through the standard filter before passing it to your custom filter and pass the original value as a parameter.
For example your Angular expression would look like this:
{{myDate | date: 'mediumDate' | relativeDate: myDate}}
And your filter:
var myApp = angular.module('myApp',[]);
myApp
.filter('relativeDate', function() {
return function(formattedDate, dateStr) {
var returnVal = formattedDate,
today = new Date(),
evalDate = new Date(dateStr);
if (today.getFullYear() == evalDate.getFullYear() &&
today.getMonth() == evalDate.getMonth() &&
today.getDate() == evalDate.getDate()) {
returnVal = 'Today'
}
return returnVal
}
})
.controller('myAppCtrl', ['$scope', function myAppCntrl($scope) {
$scope.myDate = "2001-01-01T01:01:01";
});