如何在 Angular 中呈现后端数据
How to render backend data in Angular
我有后端数据显示,但我正在尝试使用扩展面板呈现数据,但不知道该怎么做 如果我能得到任何建议或帮助,我将不胜感激。
TS
constructor(private HelpService: HelpService) {}
helpSection: {[key: string]: HelpSection } = {};
helpSection$ = this.HelpService.getHelpSection();
ngOnInit(): void {
this.HelpService.getHelpSection().subscribe(() => {
} )
}
HTML
<mat-expansion-panel>
<mat-expansion-panel-header style="align-items: center;">
<div *ngFor= "let help of helpSection$ | async">{{help.sectionName}}</div>
</mat-expansion-panel-header>
<a mat-list-item (click)="clicked(1)">Here it will display subSections</a>
</mat-expansion-panel>
*ngFor 需要在“mat-expansion-panel”标签中
<mat-expansion-panel *ngFor="let help of helpSection$ | async">
您可以遍历父级 <mat-expansion-panel>
<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(1)">Here it will display subSections</a>
</mat-expansion-panel>
造型
.exp-panel {
padding: 30px;
margin-bottom: 20px;
}
我有后端数据显示,但我正在尝试使用扩展面板呈现数据,但不知道该怎么做 如果我能得到任何建议或帮助,我将不胜感激。
TS
constructor(private HelpService: HelpService) {}
helpSection: {[key: string]: HelpSection } = {};
helpSection$ = this.HelpService.getHelpSection();
ngOnInit(): void {
this.HelpService.getHelpSection().subscribe(() => {
} )
}
HTML
<mat-expansion-panel>
<mat-expansion-panel-header style="align-items: center;">
<div *ngFor= "let help of helpSection$ | async">{{help.sectionName}}</div>
</mat-expansion-panel-header>
<a mat-list-item (click)="clicked(1)">Here it will display subSections</a>
</mat-expansion-panel>
*ngFor 需要在“mat-expansion-panel”标签中
<mat-expansion-panel *ngFor="let help of helpSection$ | async">
您可以遍历父级 <mat-expansion-panel>
<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(1)">Here it will display subSections</a>
</mat-expansion-panel>
造型
.exp-panel {
padding: 30px;
margin-bottom: 20px;
}