Angular2 + ng2-Uploader UPLOAD_DIRECTIVES未定义

我试图在我的angular2应用程序中使用ng2-uploader ,我试图添加一个button点击上传行动在我看来,我试图做的文档解释https://github.com/jkuri/ng2-uploader

component.ts

 import {Component} from 'angular2/core'; import {UPLOAD_DIRECTIVES} from 'ng2-uploader/ng2-uploader'; @Component({ selector: 'demo-app', templateUrl: 'app/demo.html', directives: [UPLOAD_DIRECTIVES], }) export class DemoApp { uploadFile: any; options: Object = { url: 'http://localhost:10050/upload' }; handleUpload(data): void { if (data && data.response) { data = JSON.parse(data.response); this.uploadFile = data; } } } 

component.html

 <a href="load" class="clas1" [ng-file-select]="options" (onUpload)="handleUpload($event)"> <div> Response: {{ uploadFile | json }} </div> 

但是我在导航器中遇到这个错误:

错误:ReferenceError:UPLOAD_DIRECTIVES未定义(…)ZoneDelegate.invoke @ angular2-polyfills.js:332Zone.run @ angular2-polyfills.js:227(匿名函数)@ angular2-polyfills.js:576ZoneDelegate.invokeTask @ angular2-polyfills .js:365Zone.runTask @ angular2-polyfills.js:263drainMicroTaskQueue @angle2-polyfills.js:482ZoneTask.invoke @angle2-polyfills.js:434

因此我看了一下安装在节点上的ng2-uploader组件,它看起来像这样:

 ///<reference path="../../node_modules/angular2/typings/browser.d.ts"/> import {Ng2Uploader} from './src/services/ng2-uploader'; import {NgFileSelect} from './src/directives/ng-file-select'; import {NgFileDrop} from './src/directives/ng-file-drop'; export * from './src/services/ng2-uploader'; export * from './src/directives/ng-file-select'; export * from './src/directives/ng-file-drop'; export default { directives: [NgFileSelect, NgFileDrop], providers: [Ng2Uploader] } export const UPLOAD_DIRECTIVES: [any] = [NgFileSelect, NgFileDrop]; 

所以它看起来像一切都是正确的,任何人都知道如何修复,也许我应该添加一些东西到我的boot.ts或我的index.html ,但究竟是什么?

我会尝试在您的主HTML文件中的以下SystemJSconfiguration:

 <script> System.config({ map: { 'ng2-uploader': 'node_modules/ng2-uploader' }, packages: { (...) 'ng2-uploader': { format: 'register', defaultExtension: 'js' } } }); (...) </script>