sell.component.html:
<p-fileUpload #fileInput name="fileIcon"
url="rest/batch/file/multimedia/"></p-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 { }
我正在尝试使用“选择”,“上传”,“取消”按钮在我的表单中使用上传primeNg文件的图像上传。 当我尝试在我的应用程序模块中使用标记时,它显示错误,因为“P-fileupload”不是元素
答案 0 :(得分:1)
将应用模块中的导入更改为:
从'primeng / components / fileupload / fileupload'导入{FileUploadModule};
答案 1 :(得分:1)
在app.module.ts中,您从未完全导入PrimeNG文件上传量。请注意FileUploadModule是如何从ng2-file-upload而不是PrimeNG的。您在顶部导入它,但您需要将FileUpload添加到导入:[]。