Angular 4 HttpClient Query Parameters

I have been looking for a way to pass query parameters into an API call with the new HttpClientModule‘s HttpClient and have yet to find a solution. With the old Http module you would write something like this. getNamespaceLogs(logNamespace) { // Setup log namespace query parameter let params = new URLSearchParams(); params.set(‘logNamespace’, logNamespace); this._Http.get(`${API_URL}/api/v1/data/logs`, { … Read more

How can I remove an element from a list, with lodash?

I have an object that looks like this: var obj = { “objectiveDetailId”: 285, “objectiveId”: 29, “number”: 1, “text”: “x”, “subTopics”: [{ “subTopicId”: 1, “number”: 1 }, { “subTopicId”: 2, “number”: 32 }, { “subTopicId”: 3, “number”: 22 }] } var stToDelete = 2; I have lodash installed in my application for other things. Is … Read more

lodash multi-column sortBy

There’s a nifty method to sort an array of objects based on several properties: var data = _.sortBy(array_of_objects, [‘type’, ‘name’]); However that is only for ascending sorting. Is there some handy way of defining direction per column? E.g. var data = _.sortBy(array_of_objects, [{‘type’: ‘asc’}, {‘name’: ‘desc’}]); 7 Answers 7

How to filter keys of an object with lodash?

I have an object with some keys, and I want to only keep some of the keys with their value? I tried with filter: const data = { aaa: 111, abb: 222, bbb: 333 }; const result = _.filter(data, (value, key) => key.startsWith(“a”)); console.log(result); <script src=”https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js”></script> But it prints an array: [111, 222] Which is … Read more

Importing lodash into angular2 + typescript application

I am having a hard time trying to get the lodash modules imported. I’ve setup my project using npm+gulp, and keep hitting the same wall. I’ve tried the regular lodash, but also lodash-es. The lodash npm package: (has an index.js file in the package root folder) import * as _ from ‘lodash’; Results in: error … Read more