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

[patch] Directive get ng-multiple and accept attributes too early #520

Closed
jeromemacias opened this issue Jan 27, 2015 · 6 comments
Closed

Comments

@jeromemacias
Copy link

In my application, configuration of ng-multiple and accept of the ng-file-select directive does not work.

To fix that, I need to modify the ngFileSelectdirective definition:

@@ -177,7 +177,9 @@ angularFileUpload.directive('ngFileSelect', [ '$parse', '$timeout', '$compile',
    restrict: 'AEC',
    require:'?ngModel',
    link: function(scope, elem, attr, ngModel) {
-       handleFileSelect(scope, elem, attr, ngModel, $parse, $timeout, $compile);
+       $timeout(function () {
+           handleFileSelect(scope, elem, attr, ngModel, $parse, $timeout, $compile);
+       }, 0);
    }
 }}]);

Anyone had the same issue ?

@jeromemacias jeromemacias changed the title Directive get ng-multiple and accept attributes too early [patch] Directive get ng-multiple and accept attributes too early Jan 27, 2015
@danialfarid
Copy link
Owner

Can you create a jsfiddle to show what problem you are having?

@danialfarid
Copy link
Owner

What version of the plugin are you using?

@jeromemacias
Copy link
Author

I use version 2.2.2 and angular 1.3.11. I use the directive into another directive.
See https://github.com/marmelab/ng-admin/blob/f1020a6667ed7b2c5ee60e0576d3c983c8a2bd20/src/javascripts/ng-admin/Crud/field/maFileField.js for usage.

Sorry, it will be hard to create a jsfiddle. I test the demo localy with angular 1.3.11 and angular-file-upload
2.2.2 but it works on this simple example.

@hafezd
Copy link

hafezd commented Jan 28, 2015

I have the similar issue and I think it's because the directive doesn't update the input element when attributes change, look at this fiddle: http://jsfiddle.net/z2seogbf/1/

@jeromemacias
Copy link
Author

Thanks @hafezdivandari, you guided me to a solution.

I just set the multiple and accept scope attributes on pre-link, see marmelab/ng-admin@55475a1?w=1

@danialfarid
Copy link
Owner

Since version 3.x the input file will be replaced and recompiled upon accept or multiple attributes model changes to reflect the new value for those attributes. So it should be fix since 3.0.0.

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

3 participants