angularjs - Angular select box with 2 values -


i want have select box list of price range.

example:

- 0 $2,000 - $2,000 $3,500 - $3,500 $5,000 - $5,000 $7,500 - $7,500 $10,000 - $10,000 

when user select 1 option want set budget range: instance if user clicks on - $3,500 $5,000 set following values:

$scope.var.x = 3500; $scope.var.y = 5000; 

i directly on partial if possible.

that's easy if have correctly understood angular principles. think have array contains price ranges:

$scope.ranges = [     {start : 0, end : 2000},     {start : 2000, end : 3500},     {start : 3500, end : 5000},     {start : 5000, end : infinity} ]; 

then, construct <select> menu array:

<select ng-model="selectedrange" ng-options="range '$' + range.start + ' $' + range.end range in ranges"></select> 

fiddle

notice if have list of price…

$scope.ranges = [0, 2000, 3500, 5000]; 

… it's not difficult reconstruct first object i've shown.


Comments