0.0.4 • Published 4 years ago
ng-upload-image v0.0.4
Introduction
This is a Angular component module for upload images.
Installation
Installation is done using the npm install command:
$ npm install ng-upload-image
Add Modules to app.module.ts
note: here we are using HttpClient in the package. so you need import it to your modules too.
import { NgUploadImageModule } from 'ng-upload-image';
import { HttpClient } from '@angular/common/http';
@NgModule({
declarations: [ /* ... */ ],
imports: [
/* ... */
NgUploadImageModule,
HttpClient,
],
providers: [],
bootstrap: [AppComponent],
})
Use Module
insert module selector to the ❮name❯.component.html.
basic use
<ng-upload-image
[apiUrl]= "'http://localhost:3000/uploads'"
></ng-upload-image>
Get feedback
if need to receive the uploaded response to the component then add (onResponse) event binder inside tags.
note: you have to create getUploadResponse(res) method in ❮name❯.component.html
<ng-upload-image
(onResponse)="getUploadResponse($event)"
[apiUrl]= "'http://localhost:3000/uploads'"
></ng-upload-image>
set max upload count
this count value set to max image count to upload at once.
<ng-upload-image
[maxUploadCount]="12"
(onResponse)="getUploadResponse($event)"
[apiUrl]= "'http://localhost:3000/uploads'"
></ng-upload-image>