0

I'm trying to build a basic Aurelia app.

Suppose I got a data where id = 1.

I can't seem to find a way to have 2 leading zero padding to my id using Numeral.js (http://numeraljs.com/).

I have this code:

<span>#${book.number | numberFormat:'000'}</span>

I was expecting an output like:

#001

but all I got was just

1

Ideally, it should go:

#001
#002
#003
...
#023
#024
#025
...
#135
#136
#137
etc

Does anyone know if this is possible ?

Zhang
  • 11,549
  • 7
  • 57
  • 87

1 Answers1

0

Thanks Stevies on Aurelia Gitter,

The solution is in the formatter class, we can go:

import numeral from 'numeral';

export class NumberFormatValueConverter {
  toView(value) {
    var output = new Intl.NumberFormat('en', {minimumIntegerDigits: 3, useGrouping: false}).format(value);
    return output;
  }
}
Zhang
  • 11,549
  • 7
  • 57
  • 87