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

Process viewValue within ng-repeat #129

Open russkin opened 8 years ago

russkin commented 8 years ago

Code

<div ng-app="angularApp" ng-controller="AngularCtrl" ng-init='models=[{data : "12"},{data : "34"},{data : "56"}]'>
  ng-repeat
  <div ng-repeat="model in models">
    <input type='text' ng-model="model.data" ui-mask="9-9" model-view-value="true">
        <span>Model value: {{model.data}}</span>
  </div>

  <p>without ng-repeat</p>
  <input type='text' ng-model="models[1].data" ui-mask="9-9" model-view-value="true">
    <span>Model value: {{models[1].data}}</span>
</div>

result:

ng-repeat
Model value: 12 <-- wrong! (must be 1-2) 
Model value: 3-4
Model value: 56 <-- wrong! (must be 5-6

without ng-repeat
Model value: 3-4

Code also available at link http://jsfiddle.net/9o9bke9c/

lukepfeiffer10 commented 8 years ago

I'm not exactly sure what your use case is here. Why would the data in the model be 12 but you want the ui-mask library to overwrite that value on data bind? Why wouldn't the data in the model already be in the required format if you are setting model-view-value=true, especially if you are loading that data from somewhere?