从http://ng2-uploader.com使用Angular2文件上传器时出错

时间:2016-10-18 06:34:43

标签: angular

我是Angular 2的新手。我正在尝试上传该文件。为此,我正在使用http://ng2-uploader.com。我已经浏览了他们的文档和README文件并执行了所有说明,但我在浏览器中收到此错误:

 GET http://localhost:3000/ng2-uploader 404 (Not Found)
(SystemJS) XHR error (404 Not Found) loading http://localhost:3000/ng2-uploader(…)

彻底搜索后发现我们需要在 systemjs.config.js中添加包

所以我的旧文件是:

map: {
  // our app is within the app folder
  app: 'app',
  // angular bundles
  '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
  '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
  '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
  '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
  '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
  '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
  '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
  '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
  // other libraries
  'rxjs':                      'npm:rxjs',
  'angular-in-memory-web-api': 'npm:angular-in-memory-web-api',
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
  app: {
    main: './main.js',
    defaultExtension: 'js'
  },
  rxjs: {
    defaultExtension: 'js'
  },
  'angular-in-memory-web-api': {
    main: './index.js',
    defaultExtension: 'js'
  }
}

现在我的更新文件是:

map: {
  // our app is within the app folder
  app: 'app',
  // angular bundles
  '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
  '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
  '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
  '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
  '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
  '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
  '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
  '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
  'ng2-uploader':'npm:ng2-uploader/ng2-uploader.js',
  // other libraries
  'rxjs':                      'npm:rxjs',
  'angular-in-memory-web-api': 'npm:angular-in-memory-web-api',
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
  app: {
    main: './main.js',
    defaultExtension: 'js'
  },
  rxjs: {
    defaultExtension: 'js'
  },
  'angular-in-memory-web-api': {
    main: './index.js',
    defaultExtension: 'js'
  },
  'ng2-uploader':{
    defaultExtension: 'js'
  }
}

如您所见,我在文件中添加了ng2-uploader,但现在我在浏览器中收到此错误:

GET http://localhost:3000/node_modules/ng2-uploader/src/directives/ng-file-select 404 (Not Found)
(index):16 Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:3000/node_modules/ng2-uploader/src/directives/ng-file-select(…)
GET http://localhost:3000/node_modules/ng2-uploader/src/directives/ng-file-drop 404 
GET http://localhost:3000/node_modules/ng2-uploader/src/services/ng2-uploader 404 (Not Found)

这是我的app.module.ts:

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent }   from './app.component';
import {UPLOAD_DIRECTIVES} from 'ng2-uploader';

@NgModule({
  imports:      [ BrowserModule ],
  declarations: [ AppComponent,
          UPLOAD_DIRECTIVES ],
  bootstrap:    [ AppComponent ]
})
export class AppModule { }

我知道我仍然缺少一些东西。你能帮我么。谢谢

1 个答案:

答案 0 :(得分:5)

您可以尝试此配置:

gmpy2

似乎对我有用

相关问题