简体   繁体   English

Angular2-moment与Angular2-cli安装

[英]Angular2-moment with Angular2-cli installation

I have installed angular2-moment into angular2-cli . 我已经将angular2-moment安装到angular2-cli While installing, angular2-cli does not have system.js , so where can I put these settings into? 安装时, angular2-cli没有system.js ,那么我可以将这些设置放在哪里?

https://github.com/urish/angular2-moment/#for-systemjs-users https://github.com/urish/angular2-moment/#for-systemjs-users

Also I'm also getting following error: 另外我也得到以下错误:

管道丢失

Add the moment to your package.json under dependencies : "angular2-moment": "^1.0.0-beta.1" . 时刻添加到您的package.json下, dependencies"angular2-moment": "^1.0.0-beta.1" Then install it via: npm install --save . 然后通过以下命令安装它: npm install --save

Since you most probably use TypeScript , install Types for the moment lib: npm install @types/moment --save . 由于您最有可能使用TypeScript ,因此在lib 时刻安装Typesnpm install @types/moment --save

Then you need to import the MomentModule in your desired module. 然后,您需要在所需的模块中导入MomentModule Eg.: import { MomentModule } from 'angular2-moment'; 例如: import { MomentModule } from 'angular2-moment'; .

And thats it, now you can use the moment pipes . 就是这样,现在您可以使用矩管

只需在脚本数组中的angular-cli.json中插入时刻的路径即可。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM