• Angular
  • React
  • NextJs
  • Sass

Angular uppercase and lowercase Pipe Example

By Webrecto, 20 July 2023
In this article we will learn about uppercase and lowercase pipe in our Angular application.
1 : The UpperCasePipe transform text to all upper case. Find the syntax.
{{ value_expression | uppercase }}
2 : The LowerCasePipe transform text to all lower case. Find the Syntax.
{{ value_expression | lowercase }}
3 : The uppercase and lowercase pipe are imported from CommonModule

Using uppercase

1 : Uppercase pipe with string.
<p>{{'India' | uppercase}}</p>
Output
INDIA
2 : Uppercase pipe with Object.
I have the following object.
address = {
   village : 'Raipur',
   district: 'Jaunpur'
}
Now use uppercase pipe with this object.
<p>{{address.village | uppercase}}</p>
<p>{{address.district | uppercase}}</p>
Output
RAIPUR
JAUNPUR	

Using lowercase

1 : Lowercase pipe with string.
<p>{{'WELCOME' | lowercase}}</p>
Output
welcome
2 : Lowercase pipe with Object.
<p>{{address.village | lowercase }}</p>
Output
raipur

Complete Example

uppercasepipe.component.ts
import { Component } from '@angular/core';
@Component({
	selector: 'uppercasepipe-app',
	template: `
	        <b>uppercase pipe example</b> <br/>

		<p>{{inputData | uppercase}}</p>
                
		<p>{{address.village | uppercase}}</p>

		<p [textContent] ="address.district | uppercase"></p>		
	   `
})
export class UpperCasePipeComponent {
	inputData = 'India';
	address = {
		village: 'Raipur',
		district: 'Jaunpur'
	}
} 
lowercasepipe.component.ts
import { Component } from '@angular/core';
@Component({
	selector: 'lowercasepipe-app',
	template: `
	            <b>lowercase pipe example</b> <br/>
		    <p>{{'WELCOME' | lowercase}}</p>
		    <p>{{address.village | lowercase}}</p>
		    <p [textContent] ="address.district | lowercase" > </p>
	    `
})
export class LowerCasePipeComponent {
	message = 'WELCOME!';
	address = {
		village: 'Anai',
		district: 'Bhadohi'
	}
} 
app.component.ts
import { Component } from '@angular/core';
@Component({
	selector: 'app-root',
	template: `
	         <uppercasepipe-app> </uppercasepipe-app>
	         <br/><br/>
	         <lowercasepipe-app> </lowercasepipe-app>
	 `
})
export class AppComponent { } 
app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { UpperCasePipeComponent } from './uppercasepipe.component';
import { LowerCasePipeComponent } from './lowercasepipe.component';
@NgModule({
  imports: [BrowserModule],
  declarations: [AppComponent,
    UpperCasePipeComponent,
    LowerCasePipeComponent],
  bootstrap: [AppComponent]
})
export class AppModule { }

Find the print screen of the output.
Angular uppercase and lowercase Pipe Example

Reference

Download Source Code