2

我正在尝试将使用 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.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”尝试了多种导入组合,但不适用于我。

在谷歌上搜索了许多相同的解决方案但没有帮助

有人可以帮我吗?

4

1 回答 1

0

我没有足够的声誉来发表评论,所以在这里添加它:

你在哪里导入VideoComponent它不是 app.module 的一部分?

另外,看看这个答案。好像是支持的。Video component除了缺少之外,我看不出与您的解决方案有太大区别

于 2018-10-15T12:51:10.433 回答