Angular String Operation Library
Transform a string between CamelCase, CapitalCase, ConstantCase, DotCase, HeaderCase, ParamCase, PascalCase, PathCase, SnakeCase, SentenceCase.
Installation
npm install ngx-str-cases
Usage
Edit your app.module.ts
file:
; ...imports: , ...
Now, there are two ways to use this awesome library:
- By calling the method in the component file
- By using as Pipe in the view file
You can simply use it in your view file like below:
{{'Test Match String' | camelcase}}
You can call the specific transform method in your component file:
; ...constructorprivate stringOps: StringTransform
Core
camelcase
capitalcase
constantcase
dotcase
headercase
paramcase
pascalcase
pathcase
sentencecase
snakecase
camelcase
Transform into a string with the separator denoted by the next word capitalized.
{{'Test Match String' | camelcase}}
or
; ...constructorprivate stringOps: StringTransform
capitalcase
Transform into a space separated string with each word capitalized.
{{'test match string' | capitalcase}}
or
; ...constructorprivate stringOps: StringTransform
constantcase
Transform into upper case string with an underscore between words.
{{'test Match string' | constantcase}}
or
; ...constructorprivate stringOps: StringTransform
dotcase
Transform into a lower case string with a period between words.
{{'test Match string' | dotcase}}
or
; ...constructorprivate stringOps: StringTransform
headercase
Transform into a dash separated string of capitalized words.
{{'test Match string ' | headercase}}
or
; ...constructorprivate stringOps: StringTransform
paramcase
Transform into a lower cased string with dashes between words.
{{'test Match string ' | paramcase}}
or
; ...constructorprivate stringOps: StringTransform
pascalcase
Transform into a string of capitalized words without separators.
{{'test Match string ' | pascalcase}}
or
; ...constructorprivate stringOps: StringTransform
pathcase
Transform into a lower case string with slashes between words.
{{'test Match string ' | pathcase}}
or
; ...constructorprivate stringOps: StringTransform
sentencecase
Transform into a lower case with spaces between words, then capitalize the string.
{{'test Match string ' | sentencecase}}
or
; ...constructorprivate stringOps: StringTransform
snakecase
Transform into a lower case string with underscores between words.
{{'test Match string ' | snakecase}}
or
; ...constructorprivate stringOps: StringTransform