Getting Moment.js to Work with Angular 6 and Higher
One of the reasons I blog here is so that I'll have an easy way to find things I needed to figure out, so that I don't need to figure them out again . And I really do need to keep that in mind. Today, a co-worker of mine asked me for help getting Moment.js to work with an application using Angular 7. Before I could find a solution, he found one already in the code in a different area. When I looked at the file in question, I'd written it (sigh). I didn't remember the problem (or the solution) until seeing the file again. At the time, I'd been trying to get Moment.js to work with Angular 6 . Here's the simple solution: //Moment doesn't want to behave in Angular 6. Here's the workaround. import * as moment_ from 'moment' ; const moment = moment_; And then you just the use moment constant like this: Example: payload.birthDate = moment(profile.birthDate).toDate(); I think I probably found this solution on Stack Oveflow, so I c...