Im trying to integrate ng2-file-upload module into my application.
And im getting this template error: Can't bind to 'uploader' since it isn't a known property of 'input'
UPDATE folder 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
in layout.module.ts
import { LayoutComponent } from './layout.component';
declarations: [
LayoutComponent,
in 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 {
...
}
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>
I have tried multiple combinations of imports for 'FileUploadModule' in my app.module in various posts, but none seems to work in my case.
Error Stack trace:
"Uncaught (in promise): Error: Template parse errors:↵Can't bind to 'uploader' since it isn't a known property of 'input'. ("↵ ↵
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
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