2

I am using Angular 2 and I am trying to figure out how to replace all the things I usually do with jQuery. (Is there some nice article out there mapping jQuery to Angular 2?)

I would like to implement the range slider that is available in for instance the jQuery UI library: http://jqueryui.com/slider/#range.

I am starting out with this in my html:

<div class="bar">
    <div id="slider-range" style="background-color:black; width:20px; height:20px;" (mousedown)="moveRange($event)"></div>
</div>

And I want to be able to move the #slider-range to left and right, and it should be limited to the with of .bar.

In my controller:

moveRange() {
    console.log(event.clientX);
}

Which is where I got stuck. My first problem is, how do I modify the position of #slider-range using Angular?

1 Answer 1

1

I think using style binding is an easy ways to update the position of #slider-range

<div id="slider-range" [style.left]="calculatedLeft" style="background-color:black; width:20px; height:20px;" ngStyle= (mousedown)="moveRange($event)"></div>

For more complex style bindings you can use ngStyle

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.