Skip to content
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

ng-file-rejected-model can only trigger once with watch #519

Closed
Cody-SDLGov opened this issue Jan 26, 2015 · 1 comment
Closed

ng-file-rejected-model can only trigger once with watch #519

Cody-SDLGov opened this issue Jan 26, 2015 · 1 comment

Comments

@Cody-SDLGov
Copy link

I have code that attempts to use the ng-file-rejected-model attribute along with ng-file-drop.

There are two minor issues I have with this item:

  1. It is mis-documented as ng-rejected-file-model on your API page, but not a huge deal since I can read the code
  2. It doesn't work with the ng-file-select, so I still need special code to handle other rejections (understandably given implementation limitations on those controls, if my perception of that is correct with HTML5).

My main concern, however, is that I can't seem to put a watch on the variable. I only get the event once if I try, ie:

<div class="btn btn-primary form-control" ng-file-drop allowDir="false" ng-model="myFiles"
       ng-show="dropSupported" drag-over-class="documents-dragover"   
       accept="application/xml,text/xml" ng-file-rejected-model="myRejFiles">
Click here or drag a file over to upload</div>

...

                    $scope.$watch('myRejFiles', function() {
                        if (angular.isArray($scope.myRejFiles)) {
                            $scope.myRejFiles.forEach(function(file) {
                                showRejected(file);
                            });
                        }
                    });

This code will only allow my showRejected function to be called on the first drag and drop of an invalid file.

I thought I could instead rely only on the myFiles watch, at which time I could see if myRejFiles is also set, but in that case, myRejFiles will only contain the first item(s) from the initial failed drag and drop, and will send that even if there are no rejects this time around.

Maybe I am using this wrong, or maybe there is an issue of some sort? Sorry, I have not yet been able to spend time to debug it much further.

@danialfarid
Copy link
Owner

Version 3.0.0 fixes this problem. Notice the attribute is renamed to ng-model-rejected and it is added to ng-file-selectas well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants