primeng下拉列表不显示值

时间:2020-06-12 13:01:04

标签: angular label dropdown primeng

是否有必要映射到标签和值以便在下拉菜单中显示值?

我正在尝试在下拉列表中显示枚举,但它们显示不正确!

  export enum nature
    {
        annuelle="Annuelle",
        semestrielle="Semestrielle",
        trimestrielle="Trimestrielle"

    }
 naturevalues = Object.values(nature);
 <div class="ui-grid-col-6">
                    <p-dropdown [options]="naturevalues"  formControlName="nature"></p-dropdown>
                </div>

this is the list 我可以在控制台上看到所选的值 i can see the chosen value on the console 我试图添加optionLabel =“ value”,但徒劳

1 个答案:

答案 0 :(得分:2)

Demo设置为启动选项

 naturevalues =   Object.keys(nature).map(key => ({ label: nature[key], value: key }));