Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Angular 2 custom pipe for age
import {Pipe, PipeTransform} from '@angular/core';
import * as moment from 'moment';
@Pipe({
name: 'age'
})
export class AgePipe implements PipeTransform {
transform(value: Date|moment.Moment, args: string[]): any {
if (!value) return value;
return moment().diff(value, 'years')+" Years";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment