Skip to content

Instantly share code, notes, and snippets.

@carlitomurta
Created November 22, 2019 14:10
Show Gist options
  • Save carlitomurta/ba9a462d4517220b47e765f685505f06 to your computer and use it in GitHub Desktop.
Save carlitomurta/ba9a462d4517220b47e765f685505f06 to your computer and use it in GitHub Desktop.
Pipe Angular para Agência
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'agencia'
})
export class AgenciaPipe implements PipeTransform {
transform(value: string, args?: any): any {
if (value) {
value = value.replace(/\D/g, '');
if (value.length < 4) {
value = value.padStart(4, '0');
}
}
return value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment