ui-mask icon indicating copy to clipboard operation
ui-mask copied to clipboard

Process viewValue within ng-repeat

Open russkin opened this issue 9 years ago • 1 comments

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/

russkin avatar Mar 02 '16 15:03 russkin

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?

lukepfeiffer10 avatar Mar 08 '16 00:03 lukepfeiffer10