Moment.js with Angular setup and issues

First install moment.js in your angular project by running the following code:

npm install moment –save

then import it in the component you want to use it like bellow:

 

 

import * as _moment from ‘moment’;
import {default as _rollupMoment} from ‘moment’;
const moment = _rollupMoment || _moment;
however it will give error and says (moment has no default export)
to solve this problem open your tsconfig.json file and under compiler options add the following code:
"allowSyntheticDefaultImports": true

also add the following under dependency in your package.json file if you are using angular material datepicker

“@angular/material-moment-adapter”: “5.2.1”,