I have four values with the following names :
$scope.restaurant.restaurantIsTop
$scope.restaurant.restaurantIsRecommended
$scope.restaurant.restaurantIsNew
$scope.restaurant.restaurantIsPromoted
Each of these values can be either 0 or 1. My goal is to check each value and if it is equal to 1, change it to true, otherwise set it to false.
Manually checking each variable can be done, but it is not the most efficient way, especially for multiple values. As a solution, I have created an array :
var varietyArray = ["restaurantIsTop" ,
"restaurantIsRecommended",
"restaurantIsNew",
"restaurantIsPromoted"
];
angular.forEach (varietyArray, function (val) {
console.log($scope.restaurant.val);
})
I want to check all four variables in the loop above. Any suggestions?
EDITED :
I want to display these values in Angular Material checkboxes :
<div class="col-sm-12">
<div class="md-form-group">
<md-checkbox ng-model="restaurant.restaurantIsTop ">
best
</md-checkbox>
<md-checkbox ng-model="restaurant.restaurantIsRecommended">
suggested
</md-checkbox>
<md-checkbox ng-model="restaurant.restaurantIsNew">
new
</md-checkbox>
<md-checkbox ng-model="restaurant.restaurantIsPromoted">
promote
</md-checkbox>
</div>
</div>