Angular 6:无法绑定到 'uploader'
Angular 6 : Can't bind to 'uploader'
我正在尝试将使用 ng2-file-upload 模块的视频上传到我的应用程序中。
这是我得到的错误:
ERROR in : Can't bind to 'uploader' since it isn't a known property of 'input'. (">single</label>
<input type="file" class="form-control" name="single" ng2FileSelect [ERROR ->][uploader]="uploader" />
</div>
</div>
")
app\app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { TranslateModule } from '@ngx-translate/core';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { FileUploadModule} from 'ng2-file-upload';
import { CoreModule } from '@app/core';
import { SharedModule } from '@app/shared';
import { HomeModule } from './home/home.module';
import { ShellModule } from './shell/shell.module';
import { AboutModule } from './about/about.module';
import { LoginModule } from './login/login.module';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import {AppContentModule} from '@app/app-content/appContent.module';
@NgModule({
imports: [
BrowserModule,
FormsModule,
HttpClientModule,
TranslateModule.forRoot(),
NgbModule,
CoreModule,
SharedModule,
ShellModule,
HomeModule,
AppContentModule,
AboutModule,
LoginModule,
FileUploadModule,
AppRoutingModule // must be imported as the last module as it contains the fallback route
],
declarations: [AppComponent],
providers: [
],
bootstrap: [AppComponent]
})
export class AppModule { }
video.component.ts
import {Component, Input, OnInit} from '@angular/core';
import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import { FileUploader } from 'ng2-file-upload';
@Component({
selector: 'app-video',
templateUrl: './video.component.html',
styleUrls: ['./video.component.scss']
})
export class VideoComponent implements OnInit {
@Input() data: any;
public uploader:FileUploader = new FileUploader({url:'http://46.101.253.10:3000/upload'});
constructor(private modalService: NgbModal,
private formBuilder: FormBuilder) { }
ngOnInit() {
}
}
video.component.html
<div class="form-group">
<label for="single">single</label>
<input type="file" class="form-control" name="single" ng2FileSelect [uploader]="uploader" />
</div>
我在 app.module 中尝试了 'FileUploadModule' 的多种导入组合,但对我不起作用。
在 google 上搜索了很多帖子来寻找相同的解决方案,但 none 有帮助
有人可以帮我吗?
我没有足够的声誉来评论,所以在这里添加:
您在哪里导入 VideoComponent
它不是 app.module 的一部分?
还,
看看 答案。好像是支持的。除了缺少 Video component
之外,我看不出与您的解决方案有什么不同
我正在尝试将使用 ng2-file-upload 模块的视频上传到我的应用程序中。
这是我得到的错误:
ERROR in : Can't bind to 'uploader' since it isn't a known property of 'input'. (">single</label>
<input type="file" class="form-control" name="single" ng2FileSelect [ERROR ->][uploader]="uploader" />
</div>
</div>
")
app\app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { TranslateModule } from '@ngx-translate/core';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { FileUploadModule} from 'ng2-file-upload';
import { CoreModule } from '@app/core';
import { SharedModule } from '@app/shared';
import { HomeModule } from './home/home.module';
import { ShellModule } from './shell/shell.module';
import { AboutModule } from './about/about.module';
import { LoginModule } from './login/login.module';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import {AppContentModule} from '@app/app-content/appContent.module';
@NgModule({
imports: [
BrowserModule,
FormsModule,
HttpClientModule,
TranslateModule.forRoot(),
NgbModule,
CoreModule,
SharedModule,
ShellModule,
HomeModule,
AppContentModule,
AboutModule,
LoginModule,
FileUploadModule,
AppRoutingModule // must be imported as the last module as it contains the fallback route
],
declarations: [AppComponent],
providers: [
],
bootstrap: [AppComponent]
})
export class AppModule { }
video.component.ts
import {Component, Input, OnInit} from '@angular/core';
import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import { FileUploader } from 'ng2-file-upload';
@Component({
selector: 'app-video',
templateUrl: './video.component.html',
styleUrls: ['./video.component.scss']
})
export class VideoComponent implements OnInit {
@Input() data: any;
public uploader:FileUploader = new FileUploader({url:'http://46.101.253.10:3000/upload'});
constructor(private modalService: NgbModal,
private formBuilder: FormBuilder) { }
ngOnInit() {
}
}
video.component.html
<div class="form-group">
<label for="single">single</label>
<input type="file" class="form-control" name="single" ng2FileSelect [uploader]="uploader" />
</div>
我在 app.module 中尝试了 'FileUploadModule' 的多种导入组合,但对我不起作用。
在 google 上搜索了很多帖子来寻找相同的解决方案,但 none 有帮助
有人可以帮我吗?
我没有足够的声誉来评论,所以在这里添加:
您在哪里导入 VideoComponent
它不是 app.module 的一部分?
还,
看看 Video component