This guide focuses on integrating third-party libraries that are not packaged as Angular modules in alignment with the app architecture generated by Angular CLI.
Specifically, we will look at installing Moment.js
yarn add moment
Open angular-cli.json and add moment.
{
...
"apps": [
...
"scripts": [
"../node_modules/moment/min/moment.min.js"
],
...
]
...
}
Open any components and import moment:
import * as moment from 'moment';Get current date and time:
now: string = moment().format()