填寫這份《一分鐘調查》,幫我們(開發組)做得更好!去填寫Home

TitleCasePipe

把文字轉換成標題形式。 把每個單詞的第一個字母轉成大寫形式,並把單詞的其餘部分轉成小寫形式。 單詞之間用任意空白字元進行分隔,比如空格、Tab 或換行符。

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 }}
    

Exported from

輸入值

value string

參見

使用說明

下面的例子示範瞭如何把多種字串轉成標題形式。

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>`
})
export class TitleCasePipeComponent {
}