我在 Angular 应用程序中工作,我正在开发 COVID 19 应用程序。
在这里,我有 2 个组件,其中组件 A 列出了所有州,组件 B 列出了特定州的所有区。
现在我已经以表格格式显示了组件的所有数据,当我单击该状态时,它应该加载单击状态的所有数据,当我再次单击该状态时,它应该关闭。此外,如果我点击所有地区的其他州列表,该州应该会显示出来
但我不知道把我的放在哪里,<app-componentB></app-componentB>因为如果把它放在 for 循环中,如果我尝试显示一个州的列表,它会在所有州下显示相同的地区列表
这是我的一段代码
组件A.html
<tbody *ngFor="let data of statewisedata;let i=index">
<span class="dropdown rotateDownRight"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg></span>
<tr class="state">
<td (click)="OngetState(data.state)" style="font-weight: 600;">{{data.state}}</td>
<td style="color: inherit;">{{data.confirmed}}
<span *ngIf='DailystateStatus[i]?.confirmed !==0 || DailystateStatus[i]?.confirmed < 0 ;' class="deltas" style="color: rgb(255, 7, 58);"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="19" x2="12" y2="5"></line><polyline points="5 12 12 5 19 12"></polyline>
</svg> {{DailystateStatus[i]?.confirmed}}</span>
</td>
<td style="color: inherit;">{{data.active}}</td>
<td style="color: inherit;">{{data.recovered}}</td>
<td style="color: inherit;">{{data.deaths}}</td>
</tr>
<app-district *ngIf="!showDistrict"></app-district>
</tbody>
组件A.ts
showDistrict=true
OngetState(state) {
this.cs.getState(state)
this.cs.getDataDistrictWise(state)
this.showDistrict=!this.showDistrict
}
慕容森
慕的地10843
MMMHUHU
随时随地看视频慕课网APP
相关分类