angular-slider / ngx-slider

Self-contained, mobile friendly slider component for Angular based on angularjs-slider
https://angular-slider.github.io/ngx-slider/
MIT License
388 stars 175 forks source link

core.js:6157 ERROR TypeError: control.registerOnChange is not a function #252

Open harleenarora opened 3 years ago

harleenarora commented 3 years ago

Hi,

If using reactive form, field is array and bind with ngx-slider, show error::

core.js:6157 ERROR TypeError: control.registerOnChange is not a function at setUpModelChangePipeline (forms.js:2559) at setUpControl (forms.js:2381) at FormGroupDirective.addControl (forms.js:5710) at FormControlName._setUpControl (forms.js:6285) at FormControlName.ngOnChanges (forms.js:6230) at FormControlName.rememberChangeHistoryAndInvokeOnChangesHook (core.js:1506) at callHook (core.js:2525) at callHooks (core.js:2492) at executeInitAndCheckHooks (core.js:2443) at refreshView (core.js:9428)

Code:: <ngx-slider formControlName="range" [options]="options"></ngx-slider>

this.testForm = this.fb.group({
    range:this.fb.array([0,45])
});
DustinJSilk commented 2 years ago

I fixed this by changing my field from a FormArray to a FormControl with an array value.