3
votes

sell.component.html:

   <p-fileUpload #fileInput name="fileIcon"
              url="rest/batch/file/multimedia/"></p-fileUpload>
The above is fileupload tag which i am trying to use to upload image with its progress bar.
sell.component.ts:

import { ViewChild, Component, NgModule, VERSION, OnInit } from '@angular/core';
import {BrowserModule} from '@angular/platform-browser'
import { Router } from '@angular/router';
import { MissionService } from '../app.service';
import { Configuration } from '../app.constants';
import { FormsModule } from '@angular/forms';
import { Http, Response, RequestOptions } from '@angular/http';
import { HttpClient,HttpErrorResponse,HttpHeaders,HttpRequest} from '@angular/common/http';
import { FormGroup , FormControl  } from '@angular/forms';
import { HttpParams } from '@angular/common/http/src/params';
import { Headers } from '@angular/http';
import { FileUploadModule, FileUpload } from 'primeng/components/fileupload/fileupload';

declare var $: any;
declare var google: any;

@Component({
  selector: 'app-sell',
  templateUrl: './sell.component.html',
  styleUrls: ['./sell.component.css']
})
export class SellComponent implements OnInit {}

the above is the code for child component and there only, i am trying to to use the fileupload module.

app.module.ts:

import { BrowserModule } from '@angular/platform-browser';
import { ViewChild, Component, NgModule, VERSION } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { ReactiveFormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { routing } from './app.routing';
import { Ng2CloudinaryModule } from 'ng2-cloudinary';
import { InfiniteScrollModule } from 'angular2-infinite-scroll';
import { LazyLoadImageModule } from 'ng2-lazyload-image';
import { FileUploadModule } from 'ng2-file-upload';
import { AppComponent } from './app.component';
import { Configuration } from './app.constants';
import { MissionService } from './app.service';

import { HeaderComponent } from './header/header.component';
  
import { SellComponent } from './sell/sell.component';
import { UiSwitchModule } from 'ngx-ui-switch';
import { HttpClientModule } from '@angular/common/http';
//import { CookieService } from 'ngx-cookie-service';
import { FileUpload } from 'primeng/primeng';


 
@NgModule({
  declarations: [
    AppComponent,
    HeaderComponent,
    
    SellComponent,
  ],
  imports: [
    BrowserModule.withServerTransition({ appId: 'website' }),
    InfiniteScrollModule,
    FormsModule,
    ReactiveFormsModule,
    HttpModule,
    routing,
    Ng2CloudinaryModule,
    FileUploadModule,
    LazyLoadImageModule,
    UiSwitchModule,HttpClientModule
  ],
  providers: [
    AuthGuard,
    Configuration,
    MissionService,
    HomeService,   
    ItemService,
    RegisterService,
    LoginService,
    SettingsService,
    ChangePasswordService,
    MemberProfileService,  
    TermsService
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
The above code is the main module .that is, app.module.ts and there i added fileupload module

I am trying to use image upload with primeNg file upload in my form with Choose, Upload, cancel buttons. When i am trying to use tag in my app module, it is showing the error as "P-fileupload" is not an element

2
did you import and add the module as a dependency?Aravind
Yes. First, i downloaded "primeng": "^5.2.0" through npm. then, import { FileUpload } from 'primeng/primeng'; that Fileupload got added as a dependency in "imports" as wellsowmya
can you add more code or create a working example?Aravind
Not at all getting what mistake i made.sowmya
hey sowmya, as @Aravind suggest put your code in Stackblitz, reproduce current state, and share, so others can debug your codePraveen Soni

2 Answers

2
votes

Change the import in the app module to this:


import { FileUploadModule } from 'primeng/fileupload';

1
votes

In your app.module.ts you never fully imported the PrimeNG fileupload. Notice how FileUploadModule is from ng2-file-upload not PrimeNG. You imported it at the top but you need to add FileUpload to the imports: [ ].