I trying to create an application with angular 2,and want use underscore.js library in my .ts files ,for example when i want use this function :
let myId
For a project based on the angular2-seed, I needed to:
Install underscore package:
npm install underscore --save
Add following to typings.json under globalDependencies:
"underscore": "github:DefinitelyTyped/DefinitelyTyped/underscore",
Add following under project.config.ts:
this.SYSTEM_CONFIG_DEV.paths['underscore'] =
`${this.APP_BASE}node_modules/underscore`;
this.SYSTEM_BUILDER_CONFIG.packages['underscore'] = {
main: 'underscore.js',
defaultExtension: 'js'
};
Import "_" in my ts files:
import * as _ from 'underscore';