0

is there any way to format numbers in Angular ?

I have this

applyIfRisk = function(slip) {
  _.assign(slip, {
    risk: slip.risk,
    win: Math.ceil(slip.risk * 1.67)
  });
}, applyIfWin = function(slip) {
  _.assign(slip, {
    risk: Math.ceil(slip.win * 1.11),
    win: slip.win
  });
}

which is attach to this html

<input ng-model="slip.win"
       ng-change="riskWinCalculations(slip, 'WINIFBET')"> 

<input ng-model="slip.risk"
       ng-change="riskWinCalculations(slip, 'RISKIFBET')"> 

but it is returning... let's say: 100000, and I need: 100,000

someone told me to use {{slip.win | number}} but I am not able to use it because this is a model, not an expression.

what should I do here ?

UPDATE

some post that my question is a duplicate of another which is not, the question is almost the same, but the answers doesn't help me.

Non
  • 8,409
  • 20
  • 71
  • 123
  • could you provide an example plunker ? your input is not very clear – Master Mind May 11 '15 at 22:32
  • possible duplicate of [AngularJS number input formatted view](http://stackoverflow.com/questions/24001895/angularjs-number-input-formatted-view) – Blackhole May 11 '15 at 22:32
  • @Blackhole hey ? what are you doing ? the answers in that post are not about the same I am asking here. Look at it, Yizus. – Non May 11 '15 at 22:36
  • @NietzscheProgrammer, first, no need for snidy remarks in comments... Second, you have to clarify if you expect a behavior of a mask (automatically format) or only on focus... – New Dev May 11 '15 at 22:40
  • @NewDev all I am doing is working with that model, when the model is updated in the view it returns numbers like: 111000, and I need 111,000 that's it. Someone told me to use the filter ```| number``` but I can't because it is a model. And what is 'snidy' ? – Non May 11 '15 at 22:43
  • 2
    @NietzscheProgrammer, so, in fact, the linked question (with its demo example) should help you – New Dev May 11 '15 at 22:44

1 Answers1

0

Use the number filter, here is a link to the angular documentation: https://docs.angularjs.org/api/ng/filter/number

Don P
  • 570
  • 1
  • 5
  • 12