angular-ui / ui-mask

Mask on an input field so the user can only type pre-determined pattern
https://htmlpreview.github.io/?https://github.com/angular-ui/ui-mask/master/demo/index.html
MIT License
391 stars 257 forks source link

Mask not properly formatting ng-model #199

Open Owizardo opened 7 years ago

Owizardo commented 7 years ago

Hi there,

For some reason when I try to put: <input ng-model="test" ui-mask-placeholder ui-mask-placeholder-char="space" ui-mask="9999-99-99 99:99" />

The the input field masks correctly as expected but once I enter a correct date for example 2016-12-06 00:00, the ng-model shows up as 20161200000 instead of 2016-12-06 00:00. Has anyone run into this issue before? Kinda of a deal breaker for me if it cant keep the correct format.

RafaelTaranto commented 7 years ago

Hello @Owizardo,

There is a model-view-value option to make the mask a part of the model.

Using the following code should work <input ng-model="test" ui-mask-placeholder ui-mask-placeholder-char="space" ui-mask="9999-99-99 99:99" model-view-value="true" />