I have a couple of date fields in my app. So i need to send date as time-stamp to the database .So I'm planning to write a custom pipe to modify the model value . Will that befit to my need ? or do I need to write custom directive for this ?
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({name: 'capitalize'})
export class CapitalizePipe implements PipeTransform {
transform(value: string, args: string[]): any {
if (!value) return value;
return value.replace(/\w\S*/g, function(txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
}
}