This is the archived documentation for Angular v5. Please visit angular.io to see documentation for the current version of Angular.

I18nSelectPipe

npm Package @angular/common
Module import { I18nSelectPipe } from '@angular/common';
Source common/src/pipes/i18n_select_pipe.ts
NgModule CommonModule

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

How To Use

expression | i18nSelect:mapping

Description

Where mapping is an object that indicates the text that should be displayed for different values of the provided expression. If none of the keys of the mapping match the value of the expression, 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.'};
}