I am using moment v2.22.0 in angular 5, and this is how I have imported it in module -
import * as moment from 'moment';
and using it in component as -
export class ChatComponent {
.
.
.
public moment: any = moment;
.
.
}
and when I am using it in html template -
<div>{{moment(activeTeam.createdAt).format('LL')}}</div>
it is giving me an error message that -
[Angular] Member 'moment' is not callable
can anyone tell me what I am doing wrong !!
cli (run in console)
// install moment js
npm install moment --save
component declaration (ts)
// import and declare moment
import * as moment from 'moment';
moment: any = moment;
template file (html)
// template syntax
<p>{{moment(date_time_variable).format('ll')}}</p>
Don't use any
, declare without it
import * as moment from 'moment';
moment = moment;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With