Angular Number Format Pipe

agnusdei·2023년 7월 5일
0
post-custom-banner
ng generate pipe numberFormat --skip-import
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'numberFormat',
  standalone: true,
})
export class NumberFormatPipe implements PipeTransform {
  transform(value: string | number, args: string): string {
    return value.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ',');
  }
}
{{item.totalPrice | numberFormat : ''}}

0개의 댓글