2017-06-21 55 views
2

指令遇到错误并没有为我工作:想在这里安装angular2时刻

https://github.com/urish/angular2-moment

我做

npm install --save angular2-moment 

工作得很好,然后我试图这样做:

typings install --save moment 

但得到了typings: command not found错误,那么我在我的app.module.ts文件:

import { MomentModule } from 'angular2-moment'; 

包括它在我的模块声明和入门组件阵列, 跑构建,并得到:

"Error: Unexpected module 'MomentModule' declared by the module 'AppModule' "

回答

1
import { BrowserModule } from '@angular/platform-browser'; 
import {MomentModule} from 'angular2-moment'; 
@NgModule({ 
    declarations:[/**...**/] 
    imports:  [BrowserModule,MomentModule], // did you update this line this works for me 
    bootstrap: [AppComponent], 
    providers:[ 
     /** 
     ... 

     **/ 
    ] 
}) 

这工作检查此链接https://github.com/rahulrsingh09/AngularConcepts/blob/master/src/app/app.module.ts线115

+0

无我没有把它放在那里。它在我将它放入导入并将它从声明和entryComponents数组中删除之后起作用。 – Spilot