Skip to content

Commit 5fb93b3

Browse files
committed
fix: NG0100 error when slider is used in template
Signed-off-by: Akshat Patel <[email protected]>
1 parent 4d640e8 commit 5fb93b3

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/slider/slider.component.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import {
99
ElementRef,
1010
TemplateRef,
1111
ViewChildren,
12-
QueryList
12+
QueryList,
13+
ChangeDetectorRef
1314
} from "@angular/core";
1415
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from "@angular/forms";
1516
import { EventService } from "carbon-components-angular/utils";
@@ -283,15 +284,19 @@ export class Slider implements AfterViewInit, ControlValueAccessor {
283284
protected _disabled = false;
284285
protected _focusedThumbIndex = 0;
285286

286-
constructor(protected elementRef: ElementRef, protected eventService: EventService) {}
287+
constructor(
288+
protected elementRef: ElementRef,
289+
protected eventService: EventService,
290+
private changeDetection: ChangeDetectorRef
291+
) {}
287292

288293
ngAfterViewInit() {
289294
// bind mousemove and mouseup to the document so we don't have issues tracking the mouse
290295
this.eventService.onDocument("mousemove", this.onMouseMove.bind(this));
291296
this.eventService.onDocument("mouseup", this.onMouseUp.bind(this));
292297

293298
// apply any values we got from before the view initialized
294-
this.value = this.value;
299+
this.changeDetection.detectChanges();
295300

296301
// TODO: ontouchstart/ontouchmove/ontouchend
297302

0 commit comments

Comments
 (0)