Hello I use angular material mat table so to display my data from an api. I use another api so to handle the Categories. I have two models, issues and categories. For the time I display the ID of the category. I need to display the corresponding category name instead of its id.
Any idea?
My models
export class Issue {
IssueID: string;
IssueTitle: string;
IssueContent: string;
CategoryID: number;
}
export class IssueCategory {
public CategoryID: number;
public CategoryName: string;
}
My html
...
<ng-container matColumnDef="CategoryTitle">
<mat-header-cell *matHeaderCellDef mat-sort-header>Category</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.categoryID}}</mat-cell>
</ng-container>
...
EDIT
My getAllIssues()
CategoryArray: TicketCategory[] = [];
getAllIssues(): void {
this.httpClient.get<Ticket[]>(this.API_URL).subscribe(data => {
this.dataChange.next(data);
this.data.map(issue => ({
category: this.CategoryArray.find(category => category.CategoryID === issue.CategoryID)
}));
}
}
thank you!