Can't bind to 'uploader' since it isn't a known property of 'input' #646
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
In my project, I have to upload the files in various child modules. I tried N number of combinations of declaring/importing FileSelectDirective/FileUploadModule in parent or root module as well. But it is not working fine, child modules are not able to resolve uploader and getting the error "Can't bind to 'uploader' since it isn't a known property of 'input'.
But if I declare it in only one specific child module and use upload in that module, things are working fine.
I tried all the possibilities mentioned in issue #148. but nothing worked out for me.
Any help is appreciated.
same error
This is because upload attribute is defined in ./file-upload/file-select.directive, to resolve this problem, import the FileUploadModule into your module.
e.g:
import { FileUploadModule } from "ng2-file-upload"; @NgModule({ ... imports: { ... FileUploadModule } .... })@SherryXueyingLi : not working too
@kamalkech , I had the same error, It took me 1 day to figure out how to apply the answer from @SherryXueyingLi , I'm a complete newbie with angular 2, so I can´t help you, but try to apply the solution proposed, just remember, is not just copy paste.
any update on this guys ? getting same error .
@amex4152 : for now i guess the solution is remove this module and search another.
Import FileUploadModule into the app.module.ts file
then use
in your current component
can anybody provide working code snippet for this ?
Finally able to work this out.
in app.module
import { FileUploadModule } from 'ng2-file-upload';
@NgModule({
imports: [
XXXX,
FileUploadModule,
XXX
],
in component.ts
import { FileUploader} from 'ng2-file-upload';
export class AccountProfileComponent implements OnInit {
uploader: FileUploader = new FileUploader({url: URL});
in html
<input class="btn btn-primary btn-block" type="file" ng2FileSelect [uploader]="uploader" />
This may be a little late but I ran into the same issue in my app. The previous answers are correct in their implementation, but don't work with every module configuration. My issue was that although I was importing FileUploadModule, I was still seeing the "can't bind to 'uploader'" error. This was because I was importing FileUploadModule at the root app.module instead of where it was being used.
This solution worked for me:
And then my SharedModule:
Finally, ExampleModule was declaring ExampleComponent, which is the component that actually used the FileUpload Directives:
So my SharedModule imports and exports all my shared Modules, but I still needed to import FileUploadModule in ExampleModule to tell angular that ExampleComponent has access to it.
I hope this helps some people, I know this was giving my team a headache for a while.
@SherryXueyingLi wow, sherry's sulotion is ok for me... BTW, What a coincidence...