File Upload in Angular 4

前端 未结 6 590
我在风中等你
我在风中等你 2021-02-04 14:26

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          


        
6条回答
  •  爱一瞬间的悲伤
    2021-02-04 14:51

    For common solution is to create new module like shared module. You just need create shared module like this and import shared module in app.module file

    import { NgModule } from '@angular/core';
    import { FormsModule } from '@angular/forms';
    
    import { FileSelectDirective, FileDropDirective } from 'ng2-file-upload';
    import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload';
    
    @NgModule({
         imports: [ FileUploadModule],  
         declarations: [ ],
         exports :[ FileSelectDirective, FileDropDirective, FormsModule,
                   FileUploadModule],
    })
    export class SharedModule { }
    

    just import share.module in your app.module like this.

    import { NgModule } from '@angular/core';
    import { SharedModule} from '../shared/shared.module';
    
    @NgModule({
        imports: [SharedModule],
        declarations: [],
        exports :[],
       })
    export class AppModule { }
    

    take a look on lazy loading in angular 4

提交回复
热议问题