darul75 / angular-awesome-slider

:arrows_clockwise: Angular slider control directive
http://darul75.github.io/angular-awesome-slider/
MIT License
144 stars 63 forks source link

Updating value from code #96

Closed funnygerman closed 9 years ago

funnygerman commented 9 years ago

I use your widget ng-slider. And I try to change the values (I use range values) and options also from the code depending on some user actions.

It seems that options will be refreshed, because I see everytime new bounds. But the value (the range) remains the same.

That is my code snippet:

$scope.displaySliderRangeFilter = function(property) {
    var range = diagramProcessor.getNumericMetrics();
    $scope.slvalue = range[property].min+";"+range[property].max;
    $scope.sloptions = {
        from: range[property].min,
        to: range[property].max,
        step: 1,
        dimension: ""
    };
};
funnygerman commented 9 years ago

I guess, this is the jsfiddle http://jsfiddle.net/g9e9n8xc/143/

darul75 commented 9 years ago

are you using "realtime" option, if not ok. can you invert changing options first then value and tell me if it is still wrong.

$scope.sloptions = {
    from: range[property].min,
    to: range[property].max,
    step: 1,
    dimension: ""
};
$scope.slvalue = range[property].min+";"+range[property].max;

http://jsfiddle.net/z4eugwo7/1/

funnygerman commented 9 years ago

If you didn't change slider values manually, then the button works only once. Otherwise the suggested solution doesn't work. Or better to say suggested solution doesn't work. You can also see this problem in the your jsfiddle link you sent.

samdanishaik commented 9 years ago

I am trying something similar and facing the same issue. Is it fixed for you now?

samdanishaik commented 9 years ago

For me the button works multiple times until I change the value using slider. Once I change the value using slider everything is screwed. Please help me.

darul75 commented 9 years ago

Sure guys there is a bug, on big holidays I have to fix it when back. Sorry for delay in responses.

samdanishaik commented 9 years ago

Hi Julien,

Sorry to bother you again. Can you please give a timeline for this fix. My app is currently dependent on these fixes.

Regards, Samdani Shaik.

darul75 commented 9 years ago

I might have time to look on sunday night ;) hope I will find where is issue

samdanishaik commented 9 years ago

That sounds good.

Thanks Julien.

darul75 commented 9 years ago

hi @funnygerman, @samdanishaik

problem is not about directive but how we use scope here, and is a common mistake we often make with string that are immutable and how scope uses javascript prototypal inheritance

just replace:

$scope.slvalue = "1;100";

by

$scope.slvalue = {
 value:"1;100"
};
// later in directive template
<input ng-model="slvalue.value"  type="text" id="mySlider1" slider options="sloptions" /></div>',

http://jsfiddle.net/darul75/z4eugwo7/6/

it is fine for you both ?

samdanishaik commented 9 years ago

That's great finding Julien.. Thanks for fixing it. It works awesome!!

funnygerman commented 9 years ago

Thank you, also worked for us

darul75 commented 9 years ago

cool