Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Prime-Ng dropdownlist not working at all in a dialog modal #4359


User avatar
0
squaresunion created

Hello, I am trying to use a primeng dropdownlist in a modal. Seriously I dont know whats going wrong there. Driving me nuts. Here is the dropdown in the component UI:

<p-dropdown [options]="squGenderList" [styleClass]="'squ-primeng-dropdowlist'" name="selectedGenderName" placeholder="Select gender" [(ngModel)]="selectedGender" optionLabel="name"></p-dropdown>

In the component .ts I am doing this

[code]squGenderList: GenderItem[] = [{ label: this.l('Male'), value: SquGenderEnum.Male }, { label: this.l('Female'), value: SquGenderEnum.Female }];
    selectedGender: GenderItem;

[/code:2g5vpp62]

But during saving if I want to retrieve the selected object doing this.selectedGender it doenst return the selected object. It only returns the selected value. what is wrong with that thing?


2 Answer(s)
  • User Avatar
    0
    squaresunion created

    Got it working! I had to intialized this that way:

    [code] squGenderList: SelectItem[] = [{ label: 'select Gender', value: { label: this.l('None'), value: SquGenderEnum.None } },
            { label: 'Male', value: { label: this.l('Male'), value: SquGenderEnum.Male } },
            { label: 'Female', value: { label: this.l('Female'), value: SquGenderEnum.Female } }];
        selectedGender: GenderItem = { label: this.l('None'), value: SquGenderEnum.None };
    

    [/code:eh3us77j]

  • User Avatar
    0
    ismcagdas created
    Support Team

    Thanks for the feedback @SquaresUnion :)