Wednesday, 3 July 2019

AngularJS - How to prevent input values from undesirably clearing on ng-click button press

I have an issue which I believe is related to a $digest / $apply happening in my application causing the inputs to clear when I press the "+" button in a particular row of my inputs.

How do I properly prevent input values from clearing on ng-click button press?

<tr ng-repeat="event in [0,1,2,3,4,5]">
    <td>
        <div class="evt" enabled=""
             ng-show="ctrl.config.cost.done" config="cost"
             webix-ui="cost" width="30" height="30"
             type="text" id="cost" name="cost[]">
        </div>
    </td>
    <td>
        <input type="button" id="evt" ng-if="event != 5" 
               style="display:none" ng-click="ctrl.enable(event)"
               value="+">
    </td>
</tr>

Sample screenshot before button click (with inputs filled out completely)

enter image description here

Please see http://projectaim.ddns.net/#!/risk/edit/1

See http://jsfiddle.net/02Lv1s9d for an MCVE (minimal complete verifyable example)

First row of target table must be completely filled out for + button to appear and + button must be clicked to trigger the problem.



from AngularJS - How to prevent input values from undesirably clearing on ng-click button press

No comments:

Post a Comment