i have to array both have same length but index is different , what i want to filter from one array and assign to another array based on matching condition like:
if desids.TransferOrderLineItemID== tList.TransferOrderLineItemID
$scope.tList.SelectedDestinationLocationIdManyToOne = desids.dLocations
here is my code and json:
$scope.desids= [{"TransferOrderID":295,"dLocations":"My Second Location","ProductID":385323,"TransferOrderLineItemID":653},{"TransferOrderID":295,"dLocations":"test dsf - Loc 1","ProductID":385315,"TransferOrderLineItemID":654},{"TransferOrderID":295,"dLocations":"My Second Location","ProductID":385190,"TransferOrderLineItemID":655},{"TransferOrderID":295,"dLocations":"test dsf - Loc 1","ProductID":385192,"TransferOrderLineItemID":656}]
$scope.tList=[{"TransferOrderID":295,"InvItemId":79759,"TransferOrderLineItemID":653,"ProductID":385323},
{"TransferOrderID":295,"InvItemId":78689,"TransferOrderLineItemID":655,"ProductID":385190},
{"TransferOrderID":295,"InvItemId":78691,"TransferOrderLineItemID":656,"ProductID":385192},
{"TransferOrderID":295,"InvItemId":79753,"TransferOrderLineItemID":654,"ProductID":385315}]
what i was trying:
for (var i = 0; i < $scope.desids.length; i++) {
var FilteredProduct = $filter('filter')($scope.desids, { ProductID: $scope.desids[i].ProductID, TransferOrderLineItemID: $scope.desids[i].TransferOrderLineItemID });
$scope.tList[i].SelectedDestinationLocationIdManyToOne = FilteredProduct[0].dLocations;
}