填写这份《一分钟调查》,帮我们(开发组)做得更好!去填写Home

I18nSelectPipe

Generic selector that displays the string that matches the current value.

查看"说明"...

{{ value_expression | i18nSelect : mapping }}
      
      {{ value_expression | i18nSelect : mapping }}
    

NgModule

输入值

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 value.

说明

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.

使用说明

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.'}; }
      
      @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.'};
}