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.

6
  • could you provide an example plunker ? your input is not very clear Commented May 11, 2015 at 22:32
  • possible duplicate of AngularJS number input formatted view Commented May 11, 2015 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. Commented May 11, 2015 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... Commented May 11, 2015 at 22:40
  • 2
    @NietzscheProgrammer, so, in fact, the linked question (with its demo example) should help you Commented May 11, 2015 at 22:44

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

1 Comment

And?... did you actually read the question there and the most upvoted answer?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.