Answers for ".pipe angular"

3

ngchange angular 8

import { Component } from '@angular/core';

@Component({
  selector: 'my-app',
  template: `
    <input type="number" [ngModel]="percent" (ngModelChange)="onPercentChange($event)" />
  `,
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {
  percent = 20;

  onPercentChange(percent: number) {
    console.log('here');  

    this.percent = percent;
  }
}
Posted by: Guest on May-04-2020
0

command to create custom pipe in angular 6

ng generate pipe personName
Posted by: Guest on June-12-2020
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