Skip to content

Instantly share code, notes, and snippets.

@odahcam
Created October 8, 2018 21:14
Show Gist options
  • Save odahcam/e427e40d3ed7b9daa2bda27e31d6facf to your computer and use it in GitHub Desktop.
Save odahcam/e427e40d3ed7b9daa2bda27e31d6facf to your computer and use it in GitHub Desktop.
Angular 6 Pipe that gets only the first word of a string.
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'firstWord'
})
export class FirstWordPipe implements PipeTransform {
transform(value: string): string {
if (!value) { return ''; }
return value.split(' ')[0];
}
}
Copy link

ghost commented Dec 22, 2020

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment