• 개요
@angular/common

I18nPluralPipe

파이프
안정화

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

파이프 사용법

{{ value_expression | i18nPlural:pluralMap:locale }}

API

    
      class I18nPluralPipe implements PipeTransform {}
    
    

transform

string
@paramvaluenumber | null | undefined

the number to be formatted

@parampluralMap{ [count: string]: string; }
@paramlocalestring | undefined

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

@returnsstring

설명

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

다음 모듈에서 내보냄

사용 시 참고사항

Example

@Component({
  selector: 'i18n-plural-pipe',
  imports: [I18nPluralPipe],
  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.',
  };
}
상세 내용으로 이동