I18nSelectPipe
通用选择器,用于显示与当前值匹配的字符串。
Generic selector that displays the string that matches the current value.
{{ value_expression | i18nSelect : mapping }}
Exported from
输入值
value | string | 要国际化的字符串。 a string to be internationalized. |
参数
mapping | object | 一个对象,指示对不同于所提供 an object that indicates the text that should be displayed for different values of the provided |
说明
如果 mapping 中的任何键都不与 value 匹配,other 键的内容如果存在则返回,否则返回空字符串。
If none of the keys of the mapping match the value, then the content of the other key is returned when present, otherwise an empty string is returned.
Further information available in the Usage Notes...
使用说明
例子
Example
@Component(
{selector: 'i18n-select-pipe', template: `<div>{{gender | i18nSelect: inviteMap}} </div>`})
export class I18nSelectPipeComponent {
gender: string = 'male';
inviteMap: any = {'male': 'Invite him.', 'female': 'Invite her.', 'other': 'Invite them.'};
}