Home:ALL Converter>Differences in importing javascript libraries between Angular 5 and 6 - which is the right syntax

Differences in importing javascript libraries between Angular 5 and 6 - which is the right syntax

Ask Time:2018-06-29T16:08:44         Author:Picci

Json Formatter

I need to import lodash into an Angular component.

In Angular 6 it seems I can use both of the following syntaxes

// either
import _ from 'lodash';
// or
import * as _ from 'lodash';

In Angular 5 it seems that only the second works. If I use the first one, _ is just undefined.

Which is the reason for the different behavior?

Author:Picci,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/51097143/differences-in-importing-javascript-libraries-between-angular-5-and-6-which-is
yy