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.

把文本转换成标题形式。 把每个单词的第一个字母转成大写形式,并把单词的其余部分转成小写形式。 单词之间用任意空白字符进行分隔,比如空格、Tab 或换行符。

{{ value_expression | titlecase }}

NgModule

输入值

valuestring

The string to transform to title case.

要转换成标题形式的字符串。

参见

使用说明

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