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

onUpload event not fired with autoUpload: false option #4

Closed
StickNitro opened this issue Aug 31, 2017 · 4 comments
Closed

onUpload event not fired with autoUpload: false option #4

StickNitro opened this issue Aug 31, 2017 · 4 comments

Comments

@StickNitro
Copy link

Hi,

I am trying to use this module (great module by the way), I want to be able to access the file and read the data url without uploading the file.

I found the autoUpload option which stops the upload but then the onUpload event does not file and ngModule is null

Can you advise how I can access the selected file?

@ogix
Copy link
Owner

ogix commented Aug 31, 2017

Hello,
onUpload is triggered when actual upload happens.
There is another output onStatusChange which I guess is what you want. Then in your component you can check for status Selected and get data url from referenced FancyImageUploaderComponent object:

@ViewChild(FancyImageUploaderComponent) imageUploader: FancyImageUploaderComponent;

imageUploaderStatusChanged(status: Status) {
  if (status === Status.Selected) {
    let dataUrl = imageUploader.imageThumbnail;
  }
}

I haven't tried this sample so not sure if that will work.

@maxpaynestory
Copy link

(onStatusChange)="imageUploaderStatusChanged($event)"

The above solution works.

@maxpaynestory
Copy link

Now the question arise how to invoke upload when autoUpload is false?

@ogix
Copy link
Owner

ogix commented Nov 2, 2017

Declare a variable for the component and call upload():

<fancy-image-uploader
    #imageUploader
    [options]="options">
</fancy-image-uploader>

<button type="button" (click)="imageUploader.upload()">Upload</button>

@ogix ogix closed this as completed Nov 22, 2017
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