About the Download

What is Lodash:

nLodash is a library of predefined complex array and object operations, which saves a lot of development time and improves the code quality & complexityn

Install and setup lodash:

nnpm install –save lodash ornyarn add lodashnnThis creates following entry in package.jsonnn’dependencies’: { ‘lodash’: ‘^4.17.10’, //… },n

Install types/lodash definition file:

nNext step is to Configure typescript definition file Lodash is a javascript library and Angular is based on typescripts. So you need to provide typescript definition files. The extension of This file always ends with d.ts. This file contains type checking information of javascript objects. package for typing is @types/lodash. if you don’t know typing information for a specific library, you can check Microsoft typing toolnnnpm install –save @types/lodashn// Ornyarn add @types/lodashnnOnce lodash and typing definition file is installed successfully, You need to do code changes as below.n

n

n

Component lodash changes:

nYou don’t need any code changes at the module level, instead, you can do changes in your component. Instead of the component, the Best way is to write a utility service which is a wrapper for this module. so that components and module are loosely coupled. For now, I am giving example for component usage.nn

n

n

n

import * as _ from ‘lodash’;n@Component({})nexport class AppComonent implements OnInit {nngOnInit() {nconsole.log(_.isEmpty({})); // returns truen}n}

n

You are all set to  use lodash with type support.

n

n

Thanks.
Types
Date Created
Licence
Support Time(in Minutes)
Support Details