Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

104
Views
Add space number angular 12

I would like to know how to add spaces to obtain a number =>1545852125458 => x xx xx xxx xxx xx.

Sorry for my English.

My html : {{ item.numberDir }}

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You should create a pipe for your needs.

Here I can share my pipe, which groups given number by 3 digits

Example: 123456789 -> 123 456 789

import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'formatNumber',
})
export class FormatNumberPipe implements PipeTransform {
  transform(value: number | string, ...args: unknown[]): string {
    let v = String(value);
    v = v.replace(/[^\d.]/g, '');
    v = v.replace(/\./g, ',');
    let parts = v.split(',');
    let result = parts[0].replace(/(?!^)(?=(?:\d{3})+$)/g, ' ');

    if (parts[1]) {
      const glueSymbol = args[0] ? args[0] : ',';
      result += glueSymbol + parts[1];
    }

    return result;
  }
}

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!