我无法使用枚举在Angular 7应用程序中填充选择下拉列表。
我有这些枚举:
Export enum GenericApiEndpointMethods {
GET,
POST
}
这是我的选择
<select [(value)]="endpoint.method" class="methodSelect">
<option *ngFor="let method of GenericApiEndpointMethods" [value]="method">{{ GenericApiEndpointMethods[method] }}</option>
</select>
但是什么都没有出现。不会填充该下拉列表,并且初始值未设置为任何值。
endpoint
是组件中的对象,而endpoint.method
是GenericApiEndpointMethods.GET
。
用枚举值填充选择下拉列表并将这些枚举的文本版本显示为下拉列表中的文本的正确方法是什么?以及如何将初始值设置为枚举之一?