Skip to content

input range& ngModel: setting min/max and value at same time #9699

Closed
@ghetolay

Description

@ghetolay

I'm submitting a bug report

Current behavior
If we have a component with the following template :

<input type="range"
  min="{{min}}"
  max="{{max}}"

  [ngModel]="value">

Setting boundary value (min or max or both) and input value at same time won't set the input value correctly.

updateRange() {
    this.min = 0;
    this.max = 50;
    this.value = 25; //won't be at the center
}

As a workaound we can delay the value update to the next tick :

updateRange() {
    this.min = 0;
    this.max = 50;
   setTimeout( () => this.value = 25, 0); //will work as expected
}

I've created a plunker : http://plnkr.co/edit/T8NKmEW7Y5EYHrpetPJk?p=preview
There is a similar issue for Angular 1 : angular/angular.js#6726

Angular version: 2.0.0-rc.1 to 2.0.0-rc.3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions