Here a loop of kpiName is executed and inside loops of subRegion also executed.
As a result 4 divs of class="col-xs-2"
are created and inside it two div(clickable divs inside filter class) are created having dynamic Id as id="filteredTabSubRegion{{index}}",id="filteredTabProductLine{{index}}"
which onclick calls some function.
The requirement is when corresponding id="filteredTabSubRegion{{index}}",id="filteredTabProductLine{{index}}"
is clicked show and hide id="filteredDataSubRegion{{index}}"
and id="filteredDataProductLine{{index}}"
of corresponding 4 divs(a,b,c,d).
app.component.ts
kpi = [a, b, c, d];
subRegion = ['China', 'India', 'Japan', 'Korea', 'SEATH'];
productLine = ['6A', '7T', '9T', 'UV', 'BA'];
loadFilterData(index,type){
console.log(index);
//---------------------angular2 implementation???------------------
if (type === 'subregion') {
// $('#filteredDataSubRegion' + index).show();
// $('#filteredDataProductLine' + index).hide();
} else {
// $('#filteredDataSubRegion' + index).hide();
// $('#ffilteredDataProductLine' + index).show();
}
}
app.component.html
<div class="col-xs-2 " *ngFor="let kpi of kpiName;let index=index;">
<div class="col-xs-12 rmpm bottomSectionKpis">
<div class="col-xs-12 rmpm filter">
<div class="col-xs-6 rmpm" id="filteredTabSubRegion{{index}}" (click)="loadFilterData(index,'subregion')" [ngClass]="{'activex': act}">Sub Region</div>
<div class="col-xs-6 rmpm" id="filteredTabProductLine{{index}}" (click)="loadFilterData(index,'productline')" [ngClass]="{'activex': activ}">Product Line</div>
</div>
<div class="col-xs-12 rmpm filterTable">
<div class="col-xs-12 rmpm " id="filteredDataSubRegion{{index}}" style="display:block">
<div class="col-xs-12 rmpm filteredDataRow" *ngFor="let subDta of subRegion;let k = index;">
<div class="col-xs-2 rmpm filteredDataIcon">
<i class="fa fa-circle" aria-hidden="true"></i>
</div>
<div class=" col-xs-7 rmpm filteredDataName">{{subRegion[k]}}</div>
<div class="col-xs-3 rmpm filteredDataShift text-center">Shift</div>
</div>
</div>
<div class="col-xs-12 rmpm " id="filteredDataProductLine{{index}}" style="display:none">
<div class="col-xs-12 rmpm filteredDataRow" *ngFor="let subDta of subRegion;let k = index;">
<div class="col-xs-2 rmpm filteredDataIcon">
<i class="fa fa-circle" aria-hidden="true"></i>
</div>
<div class=" col-xs-7 rmpm filteredDataName">{{productLine[k]}}</div>
<div class="col-xs-3 rmpm filteredDataShift text-center">Shift</div>
</div>
</div>
</div>
</div>
</div>