When I select button using ngf-select, ng-model is changed to null in ng-file-upload

1.2k views Asked by At

I have this source.

 <div class="row">
    <ptgui-imagebox name="file1" class="col-md-3" style="width: 100px;height: 100px;" ng-model="product.image" ngf-max-size="1MB" ; ngf-select></ptgui-imagebox>    
    <div class="col-md-4 hidden-sm hidden-xs">
        <div class="file-drop-zone" ngf-select ngf-drop ng-model="product.image" ngf-drag-over-class="'file-drop-zone-over'" ngf-accept="'image/*'" ngf-pattern="'*.jpg,*.jpeg,*.gif,*.png'" ngf-max-size="1MB" name="file2">
            <span class="help-block"><i class="fa fa-file-picture-o"> Drag and Drop</i></span>
        </div>
    </div>
</div>

when i click ptgui-imagebox showing image, ng-model is changed. but I want to maintain image before I select new image.

How can I do?

1

There are 1 answers

0
Ovidiu Dolha On

Try adding

ngf-model-options="{updateOn: 'change drop dropUrl paste', allowInvalid: false, debounce: 0}"

See https://github.com/danialfarid/ng-file-upload#file-select-and-drop

Note that the default options from the ng-file-upload spec include 'click' as a trigger for model change, so removing click should fix the issue.