Attempting to transfer a portion of a json object into another json object (acting as a filter), inside a for loop and under a conditional statement, proves unsuccessful.
The following method works when creating an array:
$scope.candidats=[];
for (i=0;i<omegaCandidats.length;i++){
if (omegaCandidats[i].dateRdv==date){
$scope.candidats.push(
{
"id" :omegaCandidats[i].id,
"prenom" :omegaCandidats[i].prenom,
"nom" :omegaCandidats[i].nom,
"heure" :omegaCandidats[i].heure,
"dateRdv" :omegaCandidats[i].date
}
)
};
};
This method may seem logical but sadly does not work as intended:
$scope.candidats=[];
for (i=0;i<omegaCandidats.length;i++){
if (omegaCandidats[i].dateRdv==date){
$scope.candidats[i] = omegaCandidats[i];
};
};
Although this method technically functions, it only retrieves one value from the loop rendering it pointless:
$scope.candidats=[];
for (i=0;i<omegaCandidats.length;i++){
if (omegaCandidats[i].dateRdv==date){
$scope.candidats[0] = omegaCandidats[i];
};
};