I'm currently working on an Angular program but I'm having trouble returning the correct value:
function facilityChecked(facility, search) {
var result;
search.filter(
function (v) {
var rtn = (v["facility_Item"]["text"] == facility);
if (rtn) {
var checked = (v.inherit_To_Service === 'true');
result = checked;
}
else {
result = false;
}
}
);
return result;
}
In the following code, $scope.parking should be true and $scope.toilet should be false, but they both return as false?
parking = facilityChecked('Parking', rtn.Organisation.Facility);
$scope.parking = parking;
toilet = facilityChecked('Toilet', rtn.Organisation.Facility);
$scope.toilet = toilet;
For more information, please refer to this Plunkr link