Search code examples
angularsystemjs

systemJS error with angular 2


I'm trying to use an external library in my Angular2 application (https://justindujardin.github.io/ng2-material/)

  1. I npm installed the package
  2. I imported directives in my TS file

And then it is not working, I have the following error :

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

It seems to be a SystemJS error, but what can I do to make the directives working?


Solution

  • You need to install the ng2-material library using NPM and then configure it within your SystemJS configuration:

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