如何解决如何以角形
我正在尝试在前端的每个部分显示子章节,但不确定如何执行,因此,如果能获得任何帮助或建议,我将不胜感激。
我的数据库中有两个表部分和子部分。
部分表具有ID和部分名称。
子节表具有ID,ParentId(子节表ID的外键),子节名称和文本。
在我的前端http服务中,我有两种get方法(一种用于部分,另一种用于子部分)
Services.ts
getHelpSection() {
return this.http.get<HelpSection[]>(`${environment.api.chart}/helpSection`).pipe(first());
}
getHelpSubsection() {
return this.http.get<SubSection[]>(`${environment.api.chart}/helpSubsection`).pipe(first());
}
Component.ts
Constructor(private HelpService: HelpService) {}
helpSection: {[key: string]: HelpSection } = {};
helpSection$ = this.HelpService.getHelpSection();
helpSubsection$ = this.HelpService.getHelpSubsection();
Component.html
<mat-nav-list>
<mat-expansion-panel class="exp-panel" *ngFor= "let help of helpSection$ | async">
<mat-expansion-panel-header style="align-items: center;">
<div >{{help.sectionName}}</div>
</mat-expansion-panel-header>
<a mat-list-item (click)="clicked()">Here it will display subSection Name for each sections</a>
</mat-expansion-panel>
</mat-nav-list>
现在看起来像这样。
解决方法
this.HelpService.getHelpSection()。subscribe(res => {this.helpSection $ = res});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。