1

PROBLEM:

I created one var object and inside that var object i am referring to slider scope object. so when I will use my slider it will update scope object but not update in reference object. i.e filterObject.filter.priceRange.min so for changin var object i have to do it manually then it will work

you can see my fiddle so you will understand what i am trying to say because i don't know how to explain my problem.

Workinh example: http://jsfiddle.net/kevalbhatt18/wk6xhy3k/4/

see what i did:

// this object is for slider
$scope.priceRangeSlider = {
 minValue: 100,
 maxValue: 10000,
 options: {
 floor: 100,
 ceil: 10000,
 step: 1,
 translate: function(value) {
 return 'Rs ' + value;
 }
 }
};
//var object refere to scope object 
var filterObject = {
 filter: {
 priceRange: {
 min: $scope.priceRangeSlider.minValue // refe not working 
 },
 yearRange: {},
 languageValue: [],
 formatValue: []
 }
};

HOW YOU DEBUG:

slide "price slider" so you can se changeing value below the yearslider, after changing value of price slider click on button below the price slider you will get 100 which is allocated at onload of application

Kalhan
21.9k8 gold badges71 silver badges96 bronze badges
asked Dec 19, 2015 at 6:25

1 Answer 1

1

The reason to the problem is that filterObject.filter.priceRange.min will be evaluated only once, when the controller is run for the first time.

One fix is to change it to a function:

var filterObject = {
 filter: {
 priceRange: {
 min:function () { return $scope.priceRangeSlider.minValue; }
 ...

Then:

$scope.minvaluetest = filterObject.filter.priceRange.min();

Fiddle: http://jsfiddle.net/masa671/9kjqeueo/

UPDATE:

You just need to turn the logic the other way around.

See a new Fiddle: http://jsfiddle.net/masa671/z5fkvh5b/

Now filterObject has the value that can be sent to a server.

answered Dec 19, 2015 at 8:23
Sign up to request clarification or add additional context in comments.

2 Comments

thanx for answer but i want to change value automatically so that i can pass this filterObject directly to server is it possible ? automatically means if priceRangeSlider change the value then filterObject has to change there respective value
See UPDATE for a new proposal.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.