Created
February 6, 2020 16:27
-
-
Save sunnyg1210/bb9fc144142b0353f8db8a2ec4c30eca to your computer and use it in GitHub Desktop.
Takes Camelcase string and splits it into a separated word string in Angular
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'; | |
/* | |
* Author: SVS IT Solutions LTD (www.svsitsolutions.co.uk) | |
* Takes Camelcase string and splits it into a separated word string. | |
* Usage: | |
* camelCaseString | camelCaseSplit | |
* Example: | |
* {{ "thisIsAString" | camelCaseSplit}} | |
* formats to: "this Is A String" | |
*/ | |
@Pipe({ name: 'camelCaseSplit' }) | |
export class CamelCasePipe implements PipeTransform { | |
transform(camelCase: string): string { | |
let ccSplit = camelCase.split(/(?=[A-Z])/).join(" ") | |
return ccSplit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment