简体   繁体   中英

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

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM