2

I use this library for uploading files in Angular JS.

How can I enable submit button if file was selected?

I can get access to object:

var uploader = new FileUploader({})

1 Answer 1

3

Just check the length of queue property - this is an array with selected file(s).

JS:

$scope.uploader = new FileUploader({});

HTML:

<button type="button" ng-disabled="uploader.queue.length < 1">Upload</button>

UPDATE

this is how you can check how many files were loaded:

JS:

var loaded = $filter('filter')($scope.uploader.queue, {isUploaded: true})

or show it in your template:

<span ng-bind="(uploader.queue | filter: {isUploaded: true}).length"></span>

UPDATE 2

to enable button if at least one file has been uploaded:

<button type="button" ng-disabled="(uploader.queue | filter: {isUploaded: true}).length < 1">Do something</button>
Sign up to request clarification or add additional context in comments.

3 Comments

And how to check how much files were loaded?
Updated the answer. Check module API also, it has a lot of useful info you can use github.com/nervgh/angular-file-upload/wiki/Module-API
Where user loaded in template?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.