角度拖放组件

时间:2017-09-13 07:23:49

标签: javascript angular typescript angular2-template

我尝试在角度4中使用此组件 https://github.com/jellyjs/angular2-file-drop

我有类似的东西

import { Component, OnInit } from '@angular/core';
import { FileDropDirective } from 'angular2-file-drop';


@Component({
  selector: 'app-drag-and-drop',
  template: `
    <div fileDrop
      [ngClass]="{'file-is-over': fileIsOver}"
      [options]="options"
      (fileOver)="fileOver($event)"
      (onFileDrop)="onFileDrop($event)">
      Drop file here
    </div>
  `,
  directives: [ FileDropDirective ],
  styleUrls: ['./drag-and-drop.component.scss']
})
export class DragAndDropComponent implements OnInit {
}

我有错误,从路径导入FileDropDirective没有导出成员'FileDropDirective',也有行指令错误:[FileDropDirective], 对象文字只能指定已知属性,而'组件'类型中不存在“指令”。

1 个答案:

答案 0 :(得分:0)

我改变了

import { FileDropDirective } from 'angular2-file-drop;
to
import { FileDropModule } from 'angular2-file-drop;

以及

directives to providers and working fine