Image consists of html part $scope.options = ['Low Price To High', 'High Price To Low'];
$scope.selectPriceFilter = function (priceFilter) {
if ($scope.options === 'Low Price To High') {
$scope.priceFilter = false;
}
else if ($scope.options === 'High Price To Low') {
$scope.priceFilter = true;
}
}
I'm not sure what you want. I think you want to assign true or false to priceFilter model depending on the option selected.
Your error is in the if comparation. Your model value is in priceFilter not in $scope.options.
Here you have some solutions.
Solution 1.
$scope.selectPriceFilter = function (priceFilter) {
$scope.priceFilter = (priceFilter === 'High Price To Low');
//Is the same than:
/*if (priceFilter === 'Low Price To High') {
$scope.priceFilter = false;
}
else if (priceFilter === 'High Price To Low') {
$scope.priceFilter = true;
} */
}
Solution 2. I think this solution is better.
<select class="slect select-styled" ng-model="priceFilter" ng-options="option.value as option.key for option in options">
<option value="">-- Price --</option>
</select>
Controller
function TodoCtrl($scope) {
$scope.options = [{key:'Low Price To High',value: false}, {key: 'High Price To Low', value: true}];
}
I hope this helps you
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments