【发布时间】:2021-02-09 03:15:11
【问题描述】:
目前我正在硬编码我的下拉列表选项,因为后端还没有准备好,我是这样做的
<mat-option *ngFor="let notificationType of notificationTypes"
[value]="notificationType.value">{{notificationType.content}}
</mat-option>
//I hardcoded like this for now
notificationTypes = [{ value: 1, content: "Broadcast" }, { value: 2, content: "Alert" }, { value: 3, content: "Release" }];
ngOnInit(): void {
// but now the backend get call for notificationType is ready
this.notificationService.getNotificationTypes().subscribe((response: any) => {
console.log("NOTIFICATION TYPES", response);
})
}
但现在后端获取 notificationType 已准备就绪,但我不确定如何将响应值分配给 notificationTypes 变量,因此如果我能得到任何建议或帮助将不胜感激。
我猜 id = value 和 content = message。
【问题讨论】:
标签: html angular database typescript api