【发布时间】:2017-08-23 05:43:59
【问题描述】:
我正在 Angular 4 中制作应用程序。我正在使用 dropzone.js 将文件传回。要在 Angular 4 中使用 Dropzone.js,我使用的是ngx-dropzone-wrapper。
我想在发送文件时传递一个新参数(使用“参数”选项)。参数是一个返回字符串的函数,用户单击时结果会发生变化。它实际上是一个 Singleton,它的第一次创建是在 app.component.ts 文件中的 ngOnInit() 函数中。
我的 app.module.ts 看起来像这样(dropzone.js 模块被添加到项目中):
import { DropzoneModule, DropzoneConfigInterface } from 'ngx-dropzone-wrapper';
const DROPZONE_CONFIG: DropzoneConfigInterface = {
url: 'http://localhost:81/api/createFiles',
maxFilesize: 50,
acceptedFiles: 'image/*',
params: { 'whereToCreate': **the function goes here** }
};
@NgModule({
...
imports: [
...
DropzoneModule.forRoot(DROPZONE_CONFIG)
我的 HTML 使用了 ngx-dropzone-wrapper(它与 github of ngx-dropzone-wrapper 中的示例完全相同):
<dropzone [config]="config" [message]="'Click or drag images here to upload'" (error)="onUploadError($event)" (success)="onUploadSuccess($event)"></dropzone>
【问题讨论】:
标签: angular dropzone.js