Skip to content

Instantly share code, notes, and snippets.

@carlitomurta
Created November 22, 2019 14:10
Show Gist options
  • Save carlitomurta/0c3aae2c05ca15e4b274bf4b2a084f8d to your computer and use it in GitHub Desktop.
Save carlitomurta/0c3aae2c05ca15e4b274bf4b2a084f8d to your computer and use it in GitHub Desktop.
Pipe Angular para Conta Bancária
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'conta'
})
export class ContaPipe implements PipeTransform {
transform(value: string, args?: any): any {
if (value) {
value = value.replace(/\D/g, '');
value = `${value.substr(0, value.length - 1)}-${value.substr(value.length - 1, 1)}`;
}
return value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment