No Directive annotation found on FileSelectDirective #211
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?
I'm trying to copy your demo but getting this error at runtime:
EXCEPTION: Error: Uncaught (in promise): No Directive annotation found on FileSelectDirective
can you help me?
https://angular.io/docs/ts/latest/guide/attribute-directives.html
You need to import directive at the top (ex.
import { Directive, ElementRef, Input } from '@angular/core';)and then towards the bottom above your class, add the annotations:
// class FileSelectDirective@Directive({ selector: '[ng2FileSelect]' })// class FileDropDirective@Directive({ selector: '[ng2FileDrop]' })Should add "Directive selector" in "module.ts", NOT in component.ts !!
module.ts :
import {NgModule, Directive} from '@angular/core';
import { FileSelectDirective, FileDropDirective, FileUploadModule } from 'ng2-file-upload';
@Directive({ selector: '[ng2FileDrop]' })
@NgModule({
imports: [
FileUploadModule
],
declarations: [ ],
})
component.ts
import { FileUploader } from 'ng2-file-upload/ng2-file-upload';
this works for me!