I'm facing a challenge with checkboxes related to available cars and determining whether they need to be checked based on the user's rented cars.
Essentially, I have an array of all available cars named $scope.cars, and each user has an array called $scope.user.cars. However, I am struggling to execute a function that checks if the user has rented a specific car for each checkbox.
<label ng-repeat="car in cars">
<input type="checkbox" ng-checked="hasRented({{car}});"> {{car.name}}
</label>
$scope.hasRented=function(car)
{
var x= _.keys($scope.user.cars).contains(car.id);
return x;
}
By the way, I am utilizing the _keys function from underscore.js to extract keys from the $scope.cars-array.
Could someone point out what I might be doing incorrectly?
Thank you,
Thomas