gpt4 book ai didi

Angular 2 : Can't bind to 'uploader' since it isn't a known property of 'input'

转载 作者:太空狗 更新时间:2023-10-29 17:04:07 27 4
gpt4 key购买 nike

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

我收到此模板错误:无法绑定(bind)到“ uploader ”,因为它不是“输入”的已知属性

更新文件夹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 标签

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

我在各种帖子的 app.module 中尝试了 'FileUploadModule' 的多种导入组合,但在我的情况下似乎都不起作用。

错误堆栈跟踪:

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

用谷歌搜索了很多帖子来寻找相同的解决方案:

一些引用资料是:(但没有帮助)

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

category-items.module.ts

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

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

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

关于 Angular 2 : Can't bind to 'uploader' since it isn't a known property of 'input' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45303404/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com