I18nPluralPipe

Maps a value to a string that pluralizes the value according to locale rules.

{{ value_expression | i18nPlural : pluralMap [ : locale ] }}

输入值

valuenumber

the number to be formatted

参数

pluralMap{ [count: string]: string; }

an object that mimics the ICU format, see http://userguide.icu-project.org/formatparse/messages.

localestring

a string defining the locale to use (uses the current LOCALE_IDby default).

可选. 默认值是 undefined.

说明

Example

@Component({ selector: 'i18n-plural-pipe', template: `<div>{{ messages.length | i18nPlural: messageMapping }}</div>` }) export class I18nPluralPipeComponent { messages: any[] = ['Message 1']; messageMapping: {[k: string]: string} = {'=0': 'No messages.', '=1': 'One message.', 'other': '# messages.'}; }