Data Transformer Pluck

Edit on GitHub

This document provides details about the Data Transformer Pluck service in the Components Library.

Overview

Data Transformer Pluck is an Angular Service that selects and returns a nested object by path via configuration. The datasource example below will return the value of the three key (‘123’) of the data input after receiving the response.

<spy-select
  [datasource]="{
    type: 'inline',
    data: {
      one: {
        two: {
          three: '123',  
        },
      },
    },
    transform: {
      type: 'pluck',
      path: 'one.two.three',
    },
  }"
></spy-select>

Interfaces

Below you can find interfaces for Data Transformer Pluck.

path—the name of the property from which the value needs to be retrieved. The path may contain nested properties separated by dots, just like in a Javascript language.

export interface PluckDataTransformerConfig extends DataTransformerConfig {
  path: string;
}

// Service registration
@NgModule({
  imports: [
    DataTransformerModule.withTransformers({
      pluck: PluckDataTransformerService,
    }),
  ],
})
export class RootModule {}