• Overview
@angular/common

TitleCasePipe

pipe

Transforms text to title case. Capitalizes the first letter of each word and transforms the rest of the word to lower case. Words are delimited by any whitespace character, such as a space, tab, or line-feed character.

API

  
    class TitleCasePipe implements PipeTransform {
}

transform

3 overloads
@paramvaluestring

The string to transform to title case.

@returnsstring
@paramvaluenull | undefined
@returnsnull
@paramvaluestring | null | undefined
@returnsstring | null

Description

Transforms text to title case. Capitalizes the first letter of each word and transforms the rest of the word to lower case. Words are delimited by any whitespace character, such as a space, tab, or line-feed character.


Exported by

Usage Notes

The following example shows the result of transforming various strings into title case.

          
@Component({  selector: 'titlecase-pipe',  template: `<div>    <p>{{ 'some string' | titlecase }}</p>    <!-- output is expected to be "Some String" -->    <p>{{ 'tHIs is mIXeD CaSe' | titlecase }}</p>    <!-- output is expected to be "This Is Mixed Case" -->    <p>{{ "it's non-trivial question" | titlecase }}</p>    <!-- output is expected to be "It's Non-trivial Question" -->    <p>{{ 'one,two,three' | titlecase }}</p>    <!-- output is expected to be "One,two,three" -->    <p>{{ 'true|false' | titlecase }}</p>    <!-- output is expected to be "True|false" -->    <p>{{ 'foo-vs-bar' | titlecase }}</p>    <!-- output is expected to be "Foo-vs-bar" -->  </div>`,  standalone: false,})export class TitleCasePipeComponent {}
Jump to details