question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Set formControl value manually doesn't update the view

See original GitHub issue

I’ve problems to set values manually in formControl. On ngOnInit, I call this code to test:

sliderControl: FormControl = new FormControl(360);

this.sliderControl.setValue(60)

On my view HTML, the value 60min appears and it’s ok. But the slider position, is on initial position, as you can see:

image

The position didn’t change. The expected behavior is: image.

My options:

 options: Options = {
    step: 30,
    floor: 0,
    ceil: 1439,
    showSelectionBar: true,

    getSelectionBarColor: (value: number): string => {
        if (value <= 150) {
            return 'green';
        }
        if (value <= 360) {
            return 'yellow';        }

        if (value <= 900) {
          return 'orange';
      }        
        if (value <= 1440) {
            return 'red';
        }
        return '#2AE02A';
    },

I’m using this version of ng5-slider: Version “ng5-slider”: “^1.1.14”,

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:17 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
piotrdzcommented, Jun 3, 2019

In recent changes, I re-wrote most of value update and normalisation code using rxjs, fixing a lot of similar bugs.

This should be fixed once I make the next release in the next day or two.

0reactions
steve-heinecommented, Aug 4, 2021

Just an FYI, we found that this is in fact the issue. The library expects numeric values, but works for most use-cases with strings. We switched our values to numeric and this corrected this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set formControl value manually doesn't update the view #93
I've problems to set values manually in formControl. On ngOnInit, I call this code to test: sliderControl: FormControl = new FormControl(360);.
Read more >
Angular FormControl does not update view when setValue
When setting the value manually it works ok but, if I update form value from typescript, the view does not reflect that change....
Read more >
Updating Angular Forms with patchValue or setValue
Ignoring all the function arguments and types, all it does is call setValue , which - sets the value.
Read more >
FormControlName
Syncs a FormControl in an existing FormGroup to a form control element by name. ... register multiple form controls within a form group...
Read more >
Angular Reactive Forms: Tips and Tricks
By default, whenever a value of a FormControl changes, Angular runs the control validation process. For example, if you have an input that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found