可能是您没有正确地导入ngx-file-drop模块或在组件中没有正确使用指令。请按照以下步骤进行操作:
1.安装ngx-file-drop库:
npm i ngx-file-drop
2.在您的ngModule中导入FileDropModule:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FileDropModule } from 'ngx-file-drop';
import { AppComponent } from './app.component';
@NgModule({
imports: [ BrowserModule, FileDropModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
3.在您的组件中使用FileDropDirective指令:
import { Component } from '@angular/core';
import { FileDropDirective, FileUploader } from 'ngx-file-drop';
@Component({
selector: 'my-app',
template: 'Drop your files here'
})
export class AppComponent {
public uploader:FileUploader = new FileUploader({url:'https://evening-anchorage-3159.herokuapp.com/api/'});
public fileOver(event){
console.log(event);
}
public fileDrop(event){
console.log(event);
}
}
这是一个简单的使用ngx-file-drop库的组件示例。希望这可以解决您在Angular中无法看到或读取ngx-file-drop库的问题。