No Directive annotation found on FileSelectDirective #211

Open
opened 2016-05-20 12:55:26 +00:00 by final87 · 2 comments
final87 commented 2016-05-20 12:55:26 +00:00 (Migrated from github.com)

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?

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?
donjae commented 2016-08-18 15:31:01 +00:00 (Migrated from github.com)

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]' })

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]' })`
charlesc-ai commented 2017-02-16 12:17:38 +00:00 (Migrated from github.com)

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!

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!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/ng2-file-upload#211