7

I am experimenting practice apps with Angular2 and wanted to know way to include npm modules in Angular2 app.

For example, I am trying to use Angular-uuid npm module and could not find proper way to achieve this. The module files are downloaded in /node_modules directory and also added to package.json and I am using system.js.

1) One of the option was to use sytem.import("angular-uuid"), however I still could not get module identified. 2) Do we have to still use <script src=" "></script> 3) Can we import as import * as angular-uuid from "angular-uuid";

What is the recommended way of adding npm modules?

2
  • Did you try using JSPM? Commented Nov 9, 2015 at 21:11
  • 1
    Did you find a solution to your problem ? Commented Dec 15, 2015 at 17:58

1 Answer 1

0

angular2 has its own UUID module if you want to use:

npm install angular2-uuid --save

Then in your component you can import it as :

import { UUID } from 'angular2-uuid';

To generate UUIDs:

let uuid = UUID.UUID();
console.log(uuid);

Hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.