P-dropdown initial value not set inside custom component.

UI Components for Angular
Post Reply
jonnyknowsbest
Posts: 3
Joined: 03 Feb 2020, 10:49

07 Feb 2020, 15:10

I have created a custom component containing a p-dropdown, that implements the ControlValueAccessor interface so I can use it on a reactive form by passing in the formControlName like so:

Code: Select all

<my-component options="options" optionLabel="description" formControlName="priority"></my-component>
Although changing the value in the dropdown causes the correct value to propagate up from the custom component to the form, the initial value in the drop down is not set and instead it just shows the first value in the list.

What property do i need to set on the p-dropdown to set the initial value?

jonnyknowsbest
Posts: 3
Joined: 03 Feb 2020, 10:49

10 Feb 2020, 10:29

So is there no built-in way to set the initial value of a drop-down when it is inside a custom component on a reactive form without using ngModel?

rolivares
Posts: 1
Joined: 24 Aug 2021, 21:43

24 Aug 2021, 21:49

maybe a related problem, but I'm using a dropdown inside a custom control, but event "onChange" is not propagated correctly ... I have other custom controls implementing ControlValueAccessor with no problems, but using "onChange" on dropdown and calling the "onChange" from ControlValueAccessor no controls are getting notified about the changes, other primeng controls in the same custom control are working good.

Theres a way to make dropdown work with ControlValueAccessor ?

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 20 guests