Skip to content

Instantly share code, notes, and snippets.

@JonathanDn
Created November 3, 2016 13:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JonathanDn/5e724fe62a4e26d07239c317bfca1b07 to your computer and use it in GitHub Desktop.
Save JonathanDn/5e724fe62a4e26d07239c317bfca1b07 to your computer and use it in GitHub Desktop.
Angular 2 pipe to turn string into initials
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'getInitials'
})
export class GetInitialsPipe implements PipeTransform {
transform(value: string) {
return value.replace(/[a-z]/g, '').replace(' ', '');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment