在ng2-material-select angular2中加载错误

时间:2016-09-23 08:14:17

标签: angular compiler-errors loading

我正在尝试在我的应用程序中使用ng2-material-select组件。 我在systemjs.config.js和module.ts中添加了它:

Module.ts:

这是module.ts:

import { NgModule, ApplicationRef, ModuleWithProviders } from '@angular/core';
// Ahead of Time compile
import { BrowserModule } from '@angular/platform-browser';
import { HttpModule, Http } from '@angular/http';
import { FormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';
// import { PLATFORM_DIRECTIVES, PLATFORM_PIPES, provide, enableProdMode } from '@angular/core';
import {   enableProdMode } from '@angular/core';

import { Ng2Select } from 'ng2-material-select';
import { Ng2SelectModule } from 'ng2-material-select';


@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    Ng2SelectModule 
  ],

  exports: [
    Ng2SelectModule,
  ],

  providers: [],

  declarations: [
    app_App,
    app__COMPONENTS,
    app__DIRECTIVES,
    app__PIPES,
    Ng2Select
  ],

  entryComponents: [
    App
  ],

  bootstrap: [App]
})

这是我的systemjsconfig.js中的地图:

  var map = {
    'app': '/app', // 'dist',
    '@angular': '/node_modules/@angular',
    'angular2-in-memory-web-api': '/node_modules/angular2-in-memory-web-api',
    'rxjs': '/node_modules/rxjs',
    'reflect-metadata': '/node_modules/reflect-metadata',
    'Ng2Select': '/node_modules/ng2-material-select',
    };
 var packages = {
    'app': { main: 'main.js', defaultExtension: 'js' },
    'rxjs': { defaultExtension: 'js' },
    'reflect-metadata': { defaultExtension: 'js' },
    'Ng2Select': { defaultExtension: 'js' },
  };

似乎一切都好。但是当我运行应用程序时,我得到以下错误:

  

(SystemJS)XHR错误(404 Not Found)loading http://localhost:3002/ng2-material-select patchProperty/desc.set/wrapFn@http://localhost:3002/node_modules/zone.js/dist/zone.js:647:26 ZoneDelegate.prototype.invokeTask@{ {3}} Zone.prototype.runTask @ { {3}} ZoneTask/this.invoke@http://localhost:3002/node_modules/zone.js/dist/zone.js:236:23http://localhost:3002/node_modules/zone.js/dist/zone.js:136:28加载为" ng2-material-select"来自http://localhost:3002/node_modules/zone.js/dist/zone.js:304:28"

这个配置有什么问题?

提前感谢。

1 个答案:

答案 0 :(得分:0)

您的systemjs.config.js错误,您必须设置库名称的路径,而不是要在此库中导入的元素:

var map = {
    'app': '/app', // 'dist',
    '@angular': '/node_modules/@angular',
    'angular2-in-memory-web-api': '/node_modules/angular2-in-memory-web-api',
    'rxjs': '/node_modules/rxjs',
    'reflect-metadata': '/node_modules/reflect-metadata',
    'ng2-material-select': '/node_modules/ng2-material-select',
  };
var packages = {
    'app': { main: 'main.js', defaultExtension: 'js' },
    'rxjs': { defaultExtension: 'js' },
    'reflect-metadata': { defaultExtension: 'js' },
    'ng2-material-select': { defaultExtension: 'js' },
};