角度2:无法绑定到“上载器",因为它不是“输入"的已知属性 [英] Angular 2: Can't bind to 'uploader' since it isn't a known property of 'input'

查看:106
本文介绍了角度2:无法绑定到“上载器",因为它不是“输入"的已知属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将ng2-file-upload模块集成到我的应用程序中.

Im trying to integrate ng2-file-upload module into my application.

并且我收到此模板错误:由于它不是'input'的已知属性,因此无法绑定到'uploader'

And im getting this template error: Can't bind to 'uploader' since it isn't a known property of 'input'

UPDATE文件夹str:

/src/app/app.module.ts

/src/app/components/layout/
                           layout.module.ts
                           other layout components files

                  /category-items
                            category-items.module.ts
                            category-items.component.ts

在layout.module.ts

import { LayoutComponent } from './layout.component';

declarations: [
    LayoutComponent,

在category-items.module.ts

import { CategoryItemsComponent } from './category-items.component';

import {FileUploadModule} from "ng2-file-upload";   

imports: [  ...FileUploadModule ... ]   

app \ app.module.ts

 import {FileUploadModule} from "ng2-file-upload";   

 imports: [  ...FileUploadModule ... ]  

app \ components \ layout \ category-items \ category-items.component.ts

import { FileUploader } from 'ng2-file-upload';

@Component({
  selector: 'button-view',
  template: `

  <input type="file" class="form-control" name="single" ng2FileSelect [uploader]="uploader" />   

  `
  })

export class ButtonViewComponent implements ViewCell, OnInit {

...
 public uploader:FileUploader = new FileUploader({url:'http://lcoalhost:5000/upload'});

}

@Component({
  selector: 'app-category-items',
  templateUrl: './category-items.component.html',
  styleUrls: ['./category-items.component.scss']
})

export class CategoryItemsComponent implements OnInit {
...
}

或者,如果我尝试如下操作:我意外关闭div标签

Or if i try out like below: i get unexpected closing div tag

<div ng2FileDrop
         (fileOver)-'fileOverBase($event)'
         [uploader]="uploader"
         class="well my-drop-zone">
        Base drop zone
    </div>

我在app.module中的各种帖子中尝试了'FileUploadModule'的多种导入组合,但在我的情况下似乎没有任何作用.

I have tried multiple combinations of imports for 'FileUploadModule' in my app.module in various posts, but none seems to work in my case.

错误堆栈跟踪:

未捕获(承诺):错误:模板解析错误:由于不能作为'input'的已知属性,因此无法绑定到'uploader'.(↵

"Uncaught (in promise): Error: Template parse errors:↵Can't bind to 'uploader' since it isn't a known property of 'input'. ("↵ ↵

在Google的很多帖子中都找到了相同的解决方案:

Have googled many posts for solutions for the same:

一些参考文献是:(但无济于事)

Some of the references were: (but none helping)

https://github.com/valor-software/ng2- file-upload/issues/418

https://github.com/valor-software/ng2- file-upload/issues/608

推荐答案

您需要在使用'upload'声明组件的模块中导入FileUploadModule,在您的情况下为category-items.module.ts

You need to import FileUploadModule in the module that declares the component using 'upload' which in your case would be category-items.module.ts

category-items.module.ts

import { CategoryItemsComponent } from './category-items.component';

import { FileUploadModule } from "ng2-file-upload";   //Should import HERE

imports: [  ...FileUploadModule ... ]   //RIGHT PLACE

这篇关于角度2:无法绑定到“上载器",因为它不是“输入"的已知属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆