0

I need to create input for numbers so if user entering 10000, in input will be displayed 10 000 or 10.000, but in model in will be 10000. Tried to make something like

<input type="text" ng-model="value" ng-pattern="/(\d+)(\d{3})/">

But it doesn't works(

7
  • Take a look here: docs.angularjs.org/api/ng/filter/currency Commented Aug 24, 2017 at 13:25
  • @DragoşPaulMarinescu yep, but I need to use this filter in input, and as I know it is impossible to use filter in input in angularjs Commented Aug 24, 2017 at 13:31
  • True, my bad. Look into using a custom directive, e.g : github.com/assisrafael/angular-input-masks Commented Aug 24, 2017 at 13:40
  • @mir Thank you!!! Thats what I need!) Commented Aug 24, 2017 at 14:38
  • 1
    @RoGGeR ther is an icon that says ''this comment adds somthings usefel... Commented Aug 24, 2017 at 15:00

1 Answer 1

0

Actually you need some trick here. You need to show it in a label but edit in a textbox. Some thing like this

<div ng-app ng-controller="InputCtrl">
<input id="id" type="number" ng-model="mynum1"><label for="id">{{mynum1 | number}}</label><br>

I've create a fiddle may be this is help full to you.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.