Comments (5)
Hi, thanks for your response, I already solved it. FWIW, this is the complete implementation:
Custom Dropzone:
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { DropzoneCdkModule, DropzoneComponent } from '@ngx-dropzone/cdk';
@Component({
selector: 'sk-file-zone',
standalone: true,
imports: [DropzoneCdkModule],
providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: FilezoneComponent }],
template: ` <div class="my-dropzone" (click)="onContainerClick()">
<ng-content select="[fileInput]"></ng-content>
<ng-content select="[items]"></ng-content>
</div>`,
styles: `.my-dropzone {
cursor: pointer;
text-align: center;
padding: 40px;
background: platinum;
border: 1px solid black;
}
.dragover > .my-dropzone {
border-width: 2px;
}`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class FilezoneComponent extends DropzoneComponent {
public onContainerClick(): void {
this.openFilePicker();
}
}
Using the custom dropzone
import { Component } from '@angular/core';
import { FormControl, ReactiveFormsModule } from '@angular/forms';
import { DropzoneCdkModule, FileInputValue } from '@ngx-dropzone/cdk';
import { FilezoneComponent } from '../../../../components/filezone/filezone.component';
@Component({
standalone: true,
imports: [FilezoneComponent, DropzoneCdkModule, ReactiveFormsModule],
template: `<div class="mt-3">
<sk-file-zone>
<input
type="file"
fileInput
[formControl]="fileControl"
mode="append"
multiple
/>
<div items>
@for (file of files; track file.name) {
<div>{{ file.name }}</div>
}
</div>
</sk-file-zone>
</div> `,
})
export class AssignmentWorkComponent {
public fileControl = new FormControl<FileInputValue>(null);
get files(): File[] {
const files = this.fileControl.value;
if (!files) return [];
return Array.isArray(files) ? files : [files];
}
}
The DropzoneCdkModule
must be imported on both components.
from ngx-dropzone.
Hi @mcfdez,
I guess you forgot to import the DropzoneCdkModule
into the same module which defines your ImageDropzone
.
Please test this out.
// in app.module.ts
import { DropzoneCdkModule } from '@ngx-dropzone/cdk';
@NgModule({
...
imports: [
DropzoneCdkModule,
],
declarations: [
ImageDropzoneComponent
],
...
})
export class AppModule { }
from ngx-dropzone.
Hello,
I'm having the same issue using Angular 17 and standalone components, already imported the DropzoneCdkModule
in the app main.ts
and the wrapper component, and it's showing the same error. Any help with this?
from ngx-dropzone.
Hi there, the dropzone component itself is not a standalone component.
Can you please provide an example so I can test this?
from ngx-dropzone.
Great! 👍🏼
from ngx-dropzone.
Related Issues (9)
- Cannot find module 'cdk' or its corresponding type HOT 1
- Dependency on RXJS 6.6 for Angular 16 HOT 1
- Feature request: Add option to append to current form field value HOT 7
- Suggestion: icon parameter, default preview style HOT 4
- Suggestion: support directories on drag and drop HOT 10
- Update to Angular 17 HOT 2
- Any way to make its markup work on Angular 15? HOT 3
- Suggestion: support a directory selection in Open File dialog HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngx-dropzone.