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)
-
0
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]
-
0
Thanks for the feedback @SquaresUnion :)