danialfarid / ng-file-upload

Lightweight Angular directive to upload files with optional FileAPI shim for cross browser support
MIT License
7.87k stars 1.6k forks source link

Reset errors #1998

Open LucaPrete opened 6 years ago

LucaPrete commented 6 years ago

Hello,

First of all, great plugin. Works great and it's very easy to use!

I've just an issue with displaying errors. I've seen this reported in the list of issues different times, but I've never seen a clear answer.

The plugin in my case is set to upload ngf-multiple. Here is my html code, below: <i class="fa fa-plus-square" id="vm.new_pictures" ngf-multiple="true" ngf-max-height="1000" ngf-max-width="1000" ngf-select ngf-max-size="1MB" ng-model="vm.new_pictures" ngf-keep="true" ngf-accept="'image/*'" ngf-pattern="'image/*'" ngf-model-invalid="new_pictures_errors" ngf-change="new_pictures_errors = {};" type="file"></i>

Then, I have another section in the code that shows the validation errors: `

  • Ops... One of the pictures you're trying to upload doesn't seem to have the format required. Please, make sure it reflects the criteria specified above.
  </div>

`

The desired behavior I'd like to achieve is: 1) If the picture loaded (or one of the pictures loaded) has a bad format, return the error (DONE!) 2) If the user clicks again the button to upload new pictures, after the error is thrown, the error should disappear, and the validation should start again (in case showing - or now showing - new errors)

Point 2 is what I'm not able to let work. Every time I see the error returned at step 1.

I've tried to cleanup new_pictures_errors within an ng-click bound to the i element, but it didn't to the trick....

Any thought? Suggestion?

Thanks a lot again,

-Luca

LucaPrete commented 6 years ago

Guys,

Any news on this? Thoughts? Users get very confused and it seems a quite basic thing to solve...

Any help would be really appreciated!

Thanks,

-Luca

LucaPrete commented 6 years ago

Hello again...wired there was no reply at all..still crossing my fingers to get one :) In the meantime, I've found why this happens, and I'd like to ask you if we can do a quick fix (not sure if you would consider this a bug fix or a feature request).

It turns out that the option ngf-keep="true" (which I need to use for the main picture list) keeps adding elements also to the invalid pictures array. This is totally undesired from my point of view.

The best thing would be probably to create another parameter called ngf-keep-invalid="true/false", so everybody can decide how to deal with this specific list.

Thoughts?