I created an app with angular-cli and I need to import external libraries such as underscore. I'm new to angular 2.4 and haven't used SystemJS nor Webpack before. Can someone give me a step by step guid of how to load underscore into my angular 2.4 project.
A link to github with a project created with angular-cli "latest version" with underscore would make me super happy. Reading code is nice ;)
---- Following is just to describe what makes me confused ------
From my research I found 2 alternatives to load modules.
Which one is best to use?
//package.json
"name": "angular",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor"
}
The cli creates a reference to "ng serve" in the script tag. Should I remove that line and replace it with webpack?
... If so. Do I have to set up all the settings angular already done plus mine or is it an easier way you just add my settings on top?
using following commands: For Angular CLI
npm install underscore --save // save to dependencies: required to run
npm install @types/underscore --save-dev // save to dev dependencies: required in dev mode
in Component:
import * as _ from 'underscore';
let rs = _.map([1, 2, 3], function(num){ return num * 3; });
console.log(rs);