File

src/app/modules/program-dashboard/shared/services/pd-service/pd-service.service.ts

Index

Methods

Constructor

constructor()

Methods

getFilteredData
getFilteredData(data, selectedFilters)
Parameters :
Name Optional
data No
selectedFilters No
Returns : any
import { Injectable } from "@angular/core";
import * as _ from "lodash-es";

@Injectable({
  providedIn: "root",
})
export class PdServiceService {
  constructor() {
    // This is intentional
  }

  getFilteredData(data, selectedFilters) {
    return _.filter(data, (dataItem) => {
      return _.every(selectedFilters, (value, key) => {
        if (dataItem?.[key]) {
          if (_.isArray(value)) {
            return _.some(value, (val) => val === dataItem[key]);
          }
          return value === dataItem[key];
        }
      });
    });
  }
}

results matching ""

    No results matching ""