0
我有一个场景,我需要比较名为'name'的对象属性和具有相同名称的字符串数组,并获取基于名称的比较值的长度。我不明白我需要比较什么。问题:比较和对象与对象数组
这里是我下面的代码:
$scope.pushRec=[];
//----comparing response and response.club properties
angular.forEach($scope.aResponse, function(value, key) {
$scope.aClub=value.club;
console.log($scope.aClub);
console.log(value.recruiter);
$scope.aResRec=value.recruiter;
});
//----if it matches push in to pushRec
angular.forEach($scope.aClub, function(value, key) {
console.log(value.recruiter);
$scope.aRec=value.recruiter;
console.log($scope.aClub);
if($scope.aResRec[0] == $scope.aRec){
$scope.pushRec.push($scope.aClub);
console.log($scope.pushRec.length);
}
});
您可以在代码中添加注释以获得更好的主意。 –
@VivekSingh添加评论 – anub