I need help to solve the problem, I need to show value, that calcuate by the forgroup data, because it changes I guess the error shows, but I tried many ways to solve it(like ngAfterViewChecked etc..) and nothing helped.. any suggestions?
ts
calcPercentageToUnproot() {
//:number
let trees: FOTreeInfoModel[] = this.fg.get("treesGridArray").value;
trees.forEach(element => {
if(element.actionReasonID.code==eActionReason.Unproot)
{
this.unprootSum=this.unprootSum+element.quantityOfTrees;
this.allcalcTrees=this.allcalcTrees+element.quantityOfTrees;
}
else{
this.allcalcTrees=this.allcalcTrees+element.quantityOfTrees;
}
});
if (this.allcalcTrees > 0) {
this.treesPercentageToUnproot = Math.floor(
(this.unprootSum * 100) / this.allcalcTrees
);
} else if (this.allcalcTrees == 0) {
this.treesPercentageToUnproot =null;
}
}
html
<h4 *ngIf="treesPercentageToUnproot" class="p-col-12 mr-1rem">{{treesPercentageToUnproot}}%</h4>