2017-04-01 13 views
0

Ich bin neu Winkel 2, i ng2-file-uploader zu verwenden, ich versuche, eine Datei zu laden, aber wenn ich versuche this exampleWinkel 2-Datei-Upload

import {Component} from '@angular/core'; 
import {UPLOAD_DIRECTIVES} from 'ng2-file-uploader/ng2-file-uploader'; 

@Component({ 
    selector: 'demo-app', 
    templateUrl: 'app/demo.html', 
    directives: [UPLOAD_DIRECTIVES], 
}) 
export class DemoApp { 
    uploadFile: any; 
    postId: number; 
    options: Object = { 
    url: 'http://localhost:10050/upload', 
    params: { 'post_id': this.postId } 
    }; 

    handleUpload(data): void { 
    if (data && data.response) { 
     data = JSON.parse(data.response); 
     this.uploadFile = data; 
    } 
    } 
} 

i gemäß den Richtlinien eine rote Linie erhalten zu nutzen: [UPLOAD_DIRECTIVES] ,

npm install ng2-file-uploader 

so dosieren jemand eine Idee, wie man die Direktiven richtig macht?

enter image description here

+0

http://www.angulartutorial.net/2018/01/file-upload-and-send-data-to-backend .html – Prashobh

Antwort

0

ändern für:

providers: [UPLOAD_DIRECTIVES] 

Gut