-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Upgrade to 1.x.x - TypeError: "Uploader" must be an instance of FileUploader #183
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
Comments
It appears I'm having some race conditions. It seems that |
Did you see this? |
@nervgh - yeah, I have something similar, but I'm calling the whole thing from within a directive. So it's something like: .directive('attachmentsBar', function(FileUploader) {
return {
restrict: 'E',
replace: true,
templateUrl:'attachments/_bar.html',
link: function(scope, element, attrs) {
var uploader = scope.uploader = new FileUploader();
... But what ends up happening is it hits this new code: throw new TypeError('"Uploader" must be an instance of FileUploader'); within: .directive('nvFileSelect', ['$parse', 'FileUploader', function($parse, FileUploader) {
return {
link: function(scope, element, attributes) {
var uploader = scope.$eval(attributes.uploader);
if (!(uploader instanceof FileUploader)) {
throw new TypeError('"Uploader" must be an instance of FileUploader');
}
var object = new FileUploader.FileSelect({
uploader: uploader,
element: element
});
}
};
}]) But because of the way the directive works (calling the nv-file-select directive), it seems that |
You can use ng-if directive: <element ng-if="case">
<input type="file" nv-file-select uploader="uploader"/>
</element> |
@nervgh - that wouldn't work either. Here's a plunker of my exact problem: |
For example: |
Thanks @nervgh - I think I should be able to get it working with those examples. |
What was the solution to this problem? |
I have the following template (used in a directive "A"): <input nv-file-select uploader="uploader" type="file" multiple class="hidden-file" id="attachment{{uploader._timestamp}}" /> With that directive being called from another template in another directive "B": <attachments-bar uploader="uploader"></attachments-bar> And the uploader being created in directive "B" compile/pre: compile: function() {
return {
pre: function(scope, element, attrs) {
scope.uploader = new FileUploader();
}, |
@nervgh the |
I think, to avoid confusion, in @davidwparker 's solution, the uploader=uploader attribute on the attachments-bar directive definition is unnecessary, the nv-file-select uploader=x refers to the scope.x = new FileUploader... i was able to get this working without the additional attribute but found it confusing figuring out which "uploader" was which giving the same name being used all throughout the code. Hope this helps make it even clearer. Thanks guys, i was tearing my hair out for a while on this problem |
@daleholborow - I only had to do that because I had an inner directive that needed access to the same Uploader as the parent directive. Works pretty well and is necessary for the two to talk. |
Ooooh... then that might come in handy for me as well - I hadn't realised that subtlety. Cheers mate! |
this was my first error when trying make things work. |
The ng-if = "uploader" works for me. @nervgh Thanks very much. I'm integrate this upload to angular-formly, and it works fine in formlyConfig.setType(). |
angular fileuploader is not working plz help me |
See: #574 You need to change references from "uploader" to "vm.uploader" in html file. |
ng-if also works for me.@nervgh,ありがとう :) |
When migrating, following the guide: https://github.com/nervgh/angular-file-upload/wiki/Migrate-from-0.x.x-to-1.x.x
I now get the following error whenever I use any of the directives:
The element:
Any thoughts on what I should be looking at?
The text was updated successfully, but these errors were encountered: