Closed sefo closed 7 years ago
There is no more DropzoneConfig provided by the library. You need to use the injection token to get the config. You can check the directive constructor how it gets the global config using the injection token.
I checked the directive's source but I haven't seen an injection token. Since the behaviour has changed from previous versions, can we have a concrete example on how to inject DropzoneConfig in a component?
EDIT: I found an injection token (in the interfaces file?) but that doesn't help much. An example would be welcome.
The injection token is DROPZONE_CONFIG which is used to provide the global config. So if you look at the constructor of directive:
constructor(private zone: NgZone, private renderer: Renderer2, private elementRef: ElementRef, private differs: KeyValueDiffers, @Optional() @Inject(DROPZONE_CONFIG) private defaults: DropzoneConfigInterface) {
You can see how to use it. I haven't added an example since injecting the global config into component goes to being very advanced and rare usage regarding this library. And more importantly its not specific to this library its about how Angular injection system works so documenting that does not belong to this librarys documentation. IMHO.
I moved from ng4 to ng5.
I used to import dropzone wrapper with forRoot(DROPZONE_CONFIG) but now that it's removed I import it exactly like in the docs.
The problem is in the component where I import DropzoneConfig to get config properties:
Now I get
On the component side I can add:
providers: [ { provide: DropzoneConfig, useValue: DropzoneConfig } ]
This removed my error but I can't drop files anymore.