javascriptangularformattingpipes-filters

Deleting acute accent in Angular2 using pipes


Is there any way to delete acute accent from the letters? I need lowercased and no special characters to get to the api. For now I've applied lowercase pipe -> {{f.value.cityForm | lowercase}} Example:

input: Abcdef -> abcdef (done)

input: ĄąbcćdęĘ -> aabccdee

input: ąĄĄććĆ -> aaaccc and so on


Solution

  • You can implement your own pipe with unidecode npm package.

    @Pipe({name: 'unidecode'})
    export class UnidecodePipe implements PipeTransform {
      transform(value: string): number {
        return unidecode(value).toLowerCase();
      }
    }