• 개요
@angular/common

I18nSelectPipe

파이프
안정화

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

파이프 사용법

{{ value_expression | i18nSelect:mapping }}

API

    
      class I18nSelectPipe implements PipeTransform {}
    
    

transform

string
@paramvaluestring | null | undefined

a string to be internationalized.

@parammapping{ [key: string]: string; }

an object that indicates the text that should be displayed for different values of the provided value.

@returnsstring

설명

Generic selector that displays the string that matches the current 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',
  imports: [I18nSelectPipe],
  template: `<div>{{ gender | i18nSelect: inviteMap }}</div>`,
})
export class I18nSelectPipeComponent {
  gender: string = 'male';
  inviteMap: any = {'male': 'Invite him.', 'female': 'Invite her.', 'other': 'Invite them.'};
}
상세 내용으로 이동