Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

function call in Angular using typescript creates infinite loop

import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'filterCis'
})
export class FilterCisPipe implements PipeTransform {

  public transform(cis: Structure[], baseline: Baseline): Structure[] {
    if(baseline.isHideElementsActivated){
      let newArray = [...cis]
      let result =  newArray.filter(ci => ci.checked === true).map((item,index) => {
        return {
          ...item,
          children : retreiveChildren(item.children)
        }
      })
      console.log("Result array...." , result)
      return result;
    }else{
      return cis;
    }
  }

  private retreiveChildren(children: Structure[]) : Structure[] {
    let filteredCis =  children && children.filter((ci) =>{
        if(ci.children && ci.children.length > 0){
           retreiveChildren(ci.children);
        }
        return ci.checked === true;
      }) ;
    return filteredCis;
  }

}
Comment

PREVIOUS NEXT
Code Example
Typescript :: checked a element is focused with its key pressed 
Typescript :: print gets opened whenever pdf is opened 
Typescript :: turn off suspend and sleep tagets system d 
Typescript :: js Validating nested promises 
Typescript :: typescript declare "userLanguage" 
Typescript :: typescript "variable!: type" notation 
Typescript :: Access - Open form non data entry mode 
Typescript :: typescript cast to type remove properties 
Typescript :: how to print the elements of a array using range based for loop 
Typescript :: typescript dictionary usestate 
Typescript :: change css to scss in angular online 
Typescript :: slime one 
Typescript :: yup validation typescript 
Typescript :: Environ 2.020.000 résultats (0,60 secondes) << Add Grepper Answer (a) Résultats de recherche Résultats Web 
Typescript :: INTENT 
Typescript :: yup typescript 
Typescript :: how to make the inputs become a sum python 
Typescript :: meta tag utf-8 means kya hota hai 
Cpp :: latex piecewise function 
Cpp :: #include<bits/stdc++.h 
Cpp :: how to print numbers with only 2 digits after decimal point in c++ 
Cpp :: c++ is string a number 
Cpp :: simple C++ game code 
Cpp :: how to make sure the user inputs a int and not anything else c++ 
Cpp :: qt qchar to char 
Cpp :: what is difference between single inverted and double inverted in programming languages 
Cpp :: insert at position in vector c++ 
Cpp :: eosio get time 
Cpp :: qt qimage load from file 
Cpp :: write variable to file cpp 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =