function call in Angular using typescript creates infinite loop

The solution for “function call in Angular using typescript creates infinite loop” can be found here. The following code will assist you in solving the problem.

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;
}

}

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in