• 개요
@angular/common

TitleCasePipe

파이프
안정화

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.

파이프 사용법

{{ value_expression | titlecase }}

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

설명

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.

다음 모듈에서 내보냄

사용 시 참고사항

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

@Component({
  selector: 'titlecase-pipe',
  imports: [TitleCasePipe],
  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>`,
})
export class TitleCasePipeComponent {}
상세 내용으로 이동