Open In App

Angular 10 I18nSelectPipe API

In this article, we are going to see what is I18nSelectPipe in Angular 10 and how to use it.

I18nSelectPipe is a selector that is used to displays the string that matches the current value.



Syntax:

{{ value | i18nSelect : map}}

NgModule: Module used by I18nSelectPipe is:



 

Approach: 

Input value:

Parameters:

Example 1:




import { Component, OnInit } 
from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html'
})
export class AppComponent {
    // Age Variable
    age : string = 'twenty';
  
    // Map from which I18nSelectPipe takes the value
    votin : any =
    {'twenty': 'Can Vote', 'seventeen':'Cannot Vote'};}




<!-- In Below Code I18nSelectPipe is used -->
<div>The User <b>{{age | i18nSelect: votin}}</b> </div>

Output:

Example 2:




import { Component, OnInit }
from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html'
})
export class AppComponent {
    // Age Variable
    age : string = 'seventeen';
  
    // Map from which I18nSelectPipe takes the value
    votin : any = 
    {'twenty': 'Can Vote', 'seventeen':'Cannot Vote'};}




<!-- In Below Code I18nSelectPipe is used -->
<div>The User <b>{{age | i18nSelect: votin}}</b> </div>

Output:

Reference: https://angular.io/api/common/I18nSelectPipe


Article Tags :