In the input I have a number:1000000 or 1000
I want to format it to: 1 000 000 or 1 000 respectively.
I tried to use a Pipe but it did not work out, what could be the problem?
{{ value | number : '1.1-10'}}
In the input I have a number:1000000 or 1000
I want to format it to: 1 000 000 or 1 000 respectively.
I tried to use a Pipe but it did not work out, what could be the problem?
{{ value | number : '1.1-10'}}
To reproduce in this format, do the following:
HTML
{{ value | number : '1.0-0'}} /* 0 decimal digits */
{{ value | number : '1.1-10'}} /*1.1-10 means: at least one digit before decimal point, at least 1 digit after decimal point but no more than 10 digits.*/
app.module.ts
import { LOCALE_ID } from '@angular/core';
...
@NgModule({
....
providers: [{ provide: LOCALE_ID, useValue: 'fr-FR' },....
// or your country local. For the thousands delimitation as space 'fr' works
Output
1 000 000
public splitNumber(humidity: number):string {
if(humidity == 0){
return 0+"";
}
var str = humidity.toString();
var numarray = str.split('.');
var a = new Array();
a = numarray;
return a[0] +"."+this.numberFist(parseInt(a[1],10));
}