when I'm trying to install "npm install ng2-file-upload --save" in my angular 4 application it throws
UNMET PEER DEPENDENCY @4.1.0
UNMET PEER DEPENDENCY @4.1.0
`-- ng2-file-upload@1.2.1
and upload is not working my applications throws
"Can't bind to 'uploader' since it isn't a known property of 'input'"
this is my HTML
<input type="file" ng2FileSelect [uploader]="upload" multiple formControlName="file" id="file"/>
and its Component
import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload';
import { FileSelectDirective, FileUploader } from 'ng2-file-upload/ng2-file-
upload';
export class PersonalInfoComponent implements OnInit
{
public upload:FileUploader= new FileUploader({url:""});
}
Parent Module
import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload';
@NgModule({
imports: [
..
....
..
FileUploadModule
],
export class RegistrationModule { }
and I didn't Import/change anything in AppModule(Grand Parent Module).
can someone help me on this please...
I don't think we need some extra libraries
And now we are ready to upload files with drag and drop as well as by clicking the link button and upload extra data with files.
See the complete article here Angular 4 upload files with data and web api by drag & drop
You don't need an external library to do this, check below sample code
More info
Upload images in Angular 4 without a plugin This is the article that might be worth trying. Upload images in Angular 4 without a plugin
It emphasize on these points:
HTML:
TS:
import fileupload from primeng or use simple file uploader
HTML
TS
Send this data with request return this._httpClient.post('api/controller', data);
Server
For common solution is to create new module like
shared module
. You just need create shared module like this and import shared module inapp.module
filejust import share.module in your app.module like this.
take a look on lazy loading in angular 4