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

Preview Functionality #66

Merged
merged 4 commits into from
Aug 28, 2016
Merged

Preview Functionality #66

merged 4 commits into from
Aug 28, 2016

Conversation

denkomanceski
Copy link
Contributor

@denkomanceski denkomanceski commented Aug 27, 2016

I added previewUrl flag to the options which if true, the service will create DataUrl (File reader will convert the file to base64 format) and emit it via the _previewEmitter EventEmitter. The directives NgFileDrop and NgFileSelect are listening on this event and broadcast an Output event with the data.

The handler should assign that data to a src of an img.

Example: (assuming that previewUrl flag is true in the options)
In the html:

<input id="file" type="file"
             [ng-file-select]="options"
             (onPreviewData)="getDataM($event)"
             (onUpload)="handleUpload($event)">
<img class="previewImage" [src]="previewData"/>

And the handler should just:

 getDataM(data){
        this.previewData = data;
 }

I think this way is a good approach instead of appending image of our own since everyone can customize their previewImage and put it wherever they want

@denkomanceski
Copy link
Contributor Author

I tested it in my own project and it works great.

@jkuri
Copy link
Contributor

jkuri commented Aug 27, 2016

Hi Denko, thanks for your PR. This looks good. Can you also update documentation according to this please?

@denkomanceski
Copy link
Contributor Author

Alright, I updated the README.md file as well with an example (the example is preview image + manual upload of the image)

@jkuri
Copy link
Contributor

jkuri commented Aug 28, 2016

Thanks! Merging.

@jkuri jkuri merged commit 00069db into bleenco:master Aug 28, 2016
jkuri pushed a commit that referenced this pull request Sep 2, 2016
* added preview event

* added preview event also for file-drop

* updated README (preview image and manual upload)

* previewData variable was missing
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

Successfully merging this pull request may close these issues.

2 participants