Created
November 22, 2019 14:10
-
-
Save carlitomurta/0c3aae2c05ca15e4b274bf4b2a084f8d to your computer and use it in GitHub Desktop.
Pipe Angular para Conta Bancária
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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