Gather the names of all properties from the filtered objects that meet specific criteria

Here is an example of an array:

[
  {
    "id": 82,
    "name": "fromcreate_date",
    "displayName": "From Create Date",
    "uiControl": "DATERANGE",
  },
  {
    "id": 82,
    "name": "tocreate_date",
    "displayName": "To Create Date",
    "uiControl": "DATERANGE",
  },
  {
    "id": 83,
    "name": "p_is_ut",
    "displayName": "Is UT",
    "uiControl": "HIDDEN",
   }
]

The goal here is to filter this array based on uiControl === "DATERANGE" and extract only the name property from the filtered objects into a new array like so:

outputArray = ["fromcreate_date", "tocreate_date"]

Answer №1

Here is a straightforward one-liner for you to try:

const outputArray = this.data.filter(item => item.uiControl === 'DATERANGE').map(item => item.name);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to keep an item from list A after it has been moved to list B using PrimeNg's drag and drop feature?

I am facing an issue with the drag and drop feature in PrimeNg. I have a container that contains both a table and an unordered list. My goal is to be able to drag an element from the unordered list and drop it into the table, while still retaining the drag ...

The vertical bar chart from amcharts is lacking labels

The graph attached displays labels alternatively, which appears to be a default setting of the amcharts. Is there a way we can modify it to show all the labels? Refer to the screenshot provided below. The implementation is done using amcharts in angular c ...

Error TS2315: Invalid Type Assignment for Angular 6 ModuleWithProviders

Hey there, I'm encountering an issue that's got me scratching my head. I've shared some of my code in the hopes that it might shed some light on the problem. The problem cropped up as soon as I started working on a Reactive Form. Let me s ...

Is it possible for me to input a variable into the logical process of if(isset($_FILES['whatever']))?

I have recently started learning PHP and I'm in the process of creating a dynamic page that will update based on which form buttons are clicked. The functionality is working correctly, but my goal is to enable users to upload multiple files - either P ...

Trouble arises when attempting to transfer cookies between server in Fastify and application in Svelte Kit

In the process of developing a web application, I am utilizing Fastify for the backend server and Svelte Kit for the frontend. My current challenge lies in sending cookies from the server to the client effectively. Despite configuring Fastify with the @fas ...

Creating an interface for a class instance through the implementation of a class constructor

I am working on an application where developers can specify which component they want to render a certain part. I need users to understand that they must implement an interface, but I'm struggling with correctly writing the typing. export interface I ...

When running `ng build --prod`, an error is thrown indicating that the module does not have

Whenever I try to build in Azure, I encounter an error. However, locally the command 'ng build --prod' works perfectly fine. Error: Module [path_to_file] has no static exports true Since this is for production purposes, I am hesitant to use t ...

What is the best way to populate a table view with an array of data when the Next button is tapped in iOS using Swift

Currently, I am attempting to load detailed array items into a table view. The table view consists of an array of labels and two buttons placed on the navigation bar labeled Next and Previous. When the user taps on the Next button, it will replace the arr ...

What's the issue with conducting a unit test on a component that has dependencies with further dependencies?

I am experiencing an annoying error that seems to be my mistake and I cannot figure out how to resolve it. The issue lies within a simple component which serves as a top-bar element in my web application. This component has only one dependency, the UserSe ...

The function Sync in the cp method of fs.default is not a valid function

When attempting to install TurboRepo, I encountered an issue after selecting npm. >>> TURBOREPO >>> Welcome to Turborepo! Let's get you set up with a new codebase. ? Where would you like to create your turborepo? ./my-turborepo ...

Tips for capturing a screenshot of the ESRI Map using Angular

Is there a way to capture a screenshot of the Esri map in its current state on the UI and then convert it into a PDF for download using Angular? Below is my current .ts code, but I am open to any additional suggestions. esri-map.component.html <!-- Map ...

Angular Service failing to connect with API endpoint

I have been experimenting with a new service called vpnblocker, designed to identify whether a user is utilizing a VPN or not. I am closely following the specified documentation and referencing the API variables. Despite setting up my angular service to ma ...

Encountering the error "Unable to use the '+' operator with 'symbol' type when attempting to combine $route.name"

Looking to retrieve the current route name from a template in order to pass it to a router link (specifically passing the current route to the login view so I can redirect users there after authentication). Everything functions as expected, but when perfo ...

Displaying live, real-time information using ng-apexcharts

Is there a way to leverage the results of this loop: <div *ngFor="let hour of hours | async">{{ hour.messages }}</div> and incorporate it into the [series] of an Apex Chart? An attempt like this: <apx-chart *ngFor="let hour of hours | asyn ...

Error 405: Angular encounters a method not supported while attempting to delete the entity

I have developed an application that performs CRUD operations on a list of entities. However, when attempting to delete an entity, the dialog box does not appear as expected. To start, I have a HttpService serving as the foundation for the CRUD operations ...

What is the best way to import my json information into an HTML table and customize the rows as radio buttons using only Javascript?

I am facing an issue with processing a JSON response: var jsondata = dojo.fromJson(response); There is also a string that I am working with: var jsonString = jsondata.items; The variable jsonString represents the JSON data in the file: jsonString="[ ...

Create an array of sequences from the EditText value

I am facing a challenge with 270 EditTexts. My goal is to extract the values from each EditText simultaneously and store them in a String[] for comparison. However, I'm struggling to accomplish this task. Can anyone provide guidance on how to achieve ...

Dealing with challenges in integrating ngx-masonry with Angular 14

I am currently working with Angular 14 framework and the ngx-masonry library (https://www.npmjs.com/package/ngx-masonry/v/14.0.1). However, I am facing some issues where it is not functioning correctly. I would appreciate any assistance or guidance on how ...

Using Angular 2: Implementing Router into myExceptionHandler

Within my app.module.ts, I've set up the following code: @NgModule({ declarations: [ AppComponent, ], imports: [ BrowserModule, FormsModule, ReactiveFormsModule, HttpModule ], providers: [ ...

Incorporate numerous values into the disabled attribute within an Angular application

Currently, I am attempting to include values in a disabled directive. In the code snippet below, you can see that I have disabled a button if a value matches System Admin. Now, my goal is to add additional values to this condition. Specifically, I would li ...