Answers for "pipes in angular"

1

pipes in angular 11

<p>{{name | lowercase}}</p>// Convert to LowerCase
<p>{{name | uppercase}}</p> // Convert to UpperCase
<p>{{name | titlecase}}</p> // Convert to TitleCase
<p>{{birthday | date}}</p> // Convert to Date
<p>{{value | currency: ERU}}</p> // Convert value in pounds
Posted by: Guest on February-25-2021
1

angular pipes

//component.ts file:

import {Pipe, PipeTransform} from '@angular/core';  
@Pipe ({  
  name : 'sqrt'  
})  
export class SqrtPipe implements PipeTransform {  
  transform(val : number) : number {  
    return Math.sqrt(val);  
  }  
}  

//import SqrtPipe inside your module.ts ,
import { SqrtPipe } from './app.sqrt';  
declarations: [  
      SqrtPipe,  
],  
  
//then you can use this pipe in component.html file.  
// <h2>Square root of 625 is: {{625 | sqrt}}</h2>
Posted by: Guest on February-13-2021

Browse Popular Code Answers by Language