angular - Uncaught Error : Template parse errors: 'p-fileUpload' is not a known element:

标签 angular primeng angular-forms

sell.component.html:

   <p-fileUpload #fileInput name="fileIcon"
              url="rest/batch/file/multimedia/"></p-fileUpload>
上面是 fileupload 标签,我试图用它来上传带有进度条的图像。
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 {}

上面是子组件的代码,我正在尝试使用 fileupload 模块。

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 { }
上面的代码是主模块。也就是 app.module.ts 并且我在其中添加了文件上传模块

我正在尝试在我的表单中使用带有选择、上传、取消按钮的图像上传和 primeNg 文件上传。 当我尝试在我的应用程序模块中使用标签时,它显示错误,因为“P-fileupload”不是一个元素

最佳答案

将应用模块中的导入更改为:


从'primeng/fileupload'导入{FileUploadModule};

关于angular - Uncaught Error : Template parse errors: 'p-fileUpload' is not a known element:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48739716/

相关文章:

css - PrimeNG 元素未限定范围,无法使用默认的 Angular 2 ViewEncapsulation(模拟)设置样式

angular - primeNG 数据表 - 像过滤器一样的 excel

javascript - FormControl 的 setValue 实际上有多快?

angular - 使用默认值重置表单

javascript - Angular 2 : How to access an HTTP response body?

javascript - 使用 agm 库在 Angular 2 中创建多边形

html - 在 angular2 中构建包装器指令(包装一些内容/组件)

angular - ionic 或 Angular 0r Web 组件数据网格

angular - 如何将超链接添加到 Primeng 数据表列, Angular 2 方式

angular - 如何在 Angular 2 中以 react 形式重置验证器?