2017-04-14 56 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'导入它