Questions tagged arrays

Explore the latest questions and answers asked by our top developers.

How to loop through a huge json with same key names

I have a huge json file with following structure: name: ‘xxx’, worth: [123, 456, 789] children: [ {name: ‘xxx’, worth: [987, 654, 321], children: [ {name: ‘xxx’, worth: [213, 546, 879], children: []} }, {name: ‘xxx’, worth: [987, 654, 321], children: [ name: ‘xxx’, worth: [213, 546, 879], children: [] }], ] The number of […]

By Klaxx
Published
Categorized as angular, arrays, json, typescript Tagged , , ,

using array.filter method how can i check a value from the object of the array and return different value from the same object of the array?

In the code, I am getting an array of objects from the observable and I want to check a value from an object of that array and return a different value from the same object if the condition is satisfied. How can I do that? here is the code: addresses$ = this.addressData$.pipe(map((addressData)=>{ addressData.filter((data)=> {data.deviceType === […]

By krunal
Published
Categorized as angular, arrays, filter, javascript, observable Tagged , , , ,

How do I create an array to store array elements of different data types (different interfaces)?

I have a question about 2D arrays in typescript. I want to create an array containing arrays where each element has a different data type, but the data types of these elements are all different interfaces. As you can see in the figure, the four variables (elements) that will be included in the ‘answer’ variable […]

By shinbian11
Published
Categorized as angular, arrays, typescript Tagged , ,

How do I stack elements using the object Array index?

So I’m trying to get the elements in this angular component to cascade on load, I need them in this layout (see image). How do I write the function in the TS file to pull their index position from the array that is creating the elements and use that to assign css properties position and […]

By summer basehart
Published
Categorized as angular, arrays, typescript Tagged , ,

Apply roswpan on a table using an array of objects

I have a table with 3 columns. The first column represents the description of an object "Table1" and the second represents the description of another object "Table2". The third column has check boxes that, when checked, form an array of objects. So far so good but I would like to apply a rowspan in the […]

By Jefferson Cuji
Published
Categorized as angular, arrays, html-table, object Tagged , , ,

Typescript cannot filter array

I am trying to filter an array of type object, to get the total amount of each value specified. My object is as follows: export class Member { public firstName: string; public lastName: string; public email: string; } And my array is defined: members: Member[] = []. This is then filled with Member objects, from […]

By LondonMassive
Published
Categorized as angular, arrays, filter, list, typescript Tagged , , , ,

Inserting null values at the original array indices – sorting

StackBlitz demo I am sorting an array for an *ngFor on my Angular application. So far my array is being sorted on sortId value in ascending order. It then sorts the objects with sordId: null back into the array in its original indices position, result below: Row 1 – Sort ID: null – original array […]

By Tom Rudge
Published
Categorized as angular, arrays, javascript, object, sorting Tagged , , , ,

Applying dynamic rowspan on repeating rows using an array of objects in angular

I have a table with two columns. The first column has the description of a table that is related one-to-many to the second column. The information comes to me as follows export class AppComponent { data: any; ngOnInit() { this.data = [ { Id: 1, IdTable1: 1, IdTable2: 1, Table1: { IdTable1: 1, Description: ‘Description […]

Dealing with null values position when sorting an array based on numeric values

StackBlitz example Angular application. I am sorting an array into a *ngFor to loop through the results to display in sorted order. So the question isn’t just a simple sort by numeric value. I have a list of users in an Array. Each user has a sortId of a number value, that’s straightforward. e.g. this.users.sort((a, […]

By Tom Rudge
Published
Categorized as angular, arrays, javascript, object, sorting Tagged , , , ,

Angular/Typescript Losing Keys when converting object to array

My code returns an object which is converted to an array but in the process the keys are converted to 0, 1, 2, 3 etc… The original object has descriptive keys of url, id, name etc which I wish to retain. What am I doing wrong here? How can I return an array that looks […]

By ajf0
Published
Categorized as angular, arrays, key-value, object, typescript Tagged , , , ,
1 2 3 64

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq