angular 2 的 systemJS 错误

systemJS error with angular 2

我正在尝试在我的 Angular2 应用程序中使用外部库 (https://justindujardin.github.io/ng2-material/)

  1. 我 npm 安装了包
  2. 我在我的 TS 文件中导入了指令

然后它不起作用,我有以下错误:

system.src.js:4935 GET http://localhost:5000/ng2-material/all 404 (Not Found)

这似乎是 SystemJS 错误,但我该怎么做才能使指令正常工作?

您需要使用 NPM 安装 ng2-material 库,然后在您的 SystemJS 配置中对其进行配置:

<script>
  System.config({
    defaultJSExtensions: true,
    packages: {
      app: {
        format: 'register',
        defaultExtension: false
      }
    },
    map: {
      'ng2-material': 'node_modules/ng2-material'
    }
  });
</script>