-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uploaded files list is cleared everytime file-select is clicked. #721
Comments
The best is to add the selected files to another scope variable. |
+1 |
Since version 5.0,0 you can use You can also play with |
Thanks Danial .. I ll check that out. |
@danialfarid first of all I wanted to thank you for this great component. A follow-up question on your comment: Are ngf-reset-on-click and ngf-reset-model-on-click actually implemented? I have three components pointing to the same ng-model (one preview div and two buttons with ngf-select) |
@gkohen You should use ng-model-options for reset. use |
@danialfarid, I've added these options in all the fields that have ngf-select. When I did, for some reason when selecting an image in the file dialog, the preview element stopped updating the image for the selected file. My md-model-options look as follows: Removing the debounce does not seem to make a difference. |
Could you create a jsfiddle? Do you have ng-model on that element? |
Here's the default behavior: |
That's so weird it works on the demo page. Adding 'default' to the actions makes it work but it could be the md library that does something funny here. |
By the way reset on click is the default behaviour in Chrome. So even if you remove the click it would still remove the file from the input if you click browse and then cancel the popup. So removing the click from updates would make it not behave the same cross browser. |
I'm fine with Chrome clearing out the content of the model if you do cancel (although it will be a nice workaround to have to preserve it using a watch). Is it a chrome default to clear it when the file dialog opens and you actually select rather than doing cancel? Also, are we sure that Angular Material might be causing it rather than the fact we're not dealing with a file type form element? Should I try to create a snippet without Angular Material and see if the issue persists? |
When you actually select it won't clear it. It will just replace it. |
Danial, maybe I mis-communicated. the issue I see in default behavior is the model clearing when you open the file dialog, not when I press cancel or select a file. How would checking for null when we select a file in the file dialog would help? Did you mean putting a callback on file select? |
Since chrome removes the file when you open the dialog and close it, the model should be cleared to handle this case. If you select another file the model will be updated with the new file. If you want to keep the files that user selects you can use ngf-keep. |
At this point I made the following workaround:
|
The file list is reset everytime the file-select is clicked,
resetModel(evt); // inside clickHandler()
I wanted to add files one after another to the field but whenever I click on file select the uploaded list is cleared. It would be nice if this is configurable through attributes.
The text was updated successfully, but these errors were encountered: