2017-04-14 57 views
0

我已經加入文件中角cli.json像下面如何使用CLI

"scripts": [ 
    "../node_modules/underscore/underscore.js" 
    ] 

我怎麼能導入此文件在我的組件

import * as _ from 'underscore'; // How to implement this 

獲得以下錯誤導入angular2下劃線。 。

ERROR in /Applications/MAMP/htdocs/Projects/Acadgild/frontend- 
advance/assignements/03:04:2017/custompipe/src/app/search.pipe.ts 
(2,20): Cannot find module 'underscore'. 

回答

0

在命令行上npm i -S lodash

然後在你的ts文件中做import * as _ from 'lodash'導入它