Hello everyone thanks for reading. I have a question with Angular, AngularMeteor or Meteor.
Behaviors:
When the result verCandidatos.postulados
has only one value (see the first image) it never prints it the first time. If I refresh, or I give a second click then the values appear (like image 2)
When, they are two values they always look perfect, there's never a problem
Why is this behavior so strange and why only when it comes to a value?
Then my files.
html client
my-app / imports / ui / components / vacancies / seeCandidates / seeCandidates.html
<div ng-repeat="postulado in verCandidatos.postulados">
{{postulado.candidato().nombre}}
{{postulado.candidato().apellidos}}
{{postulado.candidato().sexo}}
</div>
Next the images:
//////////// ISUE img1
//////////// ISUE img2
js in client
my-app / imports / ui \ components / vacancies / seeCandidates / verCandidates.js
imports ...
class VerCandidatos {
constructor($scope, $reactive, $stateParams) {
'ngInject';
$reactive(this).attach($scope);
this.vacanteId = $stateParams.vacanteId;
this.subscribe('vacantes.candidatosOseleccionados', ()=>
[
{vacanteId: this.vacanteId},
{estado: 1}
]
);
this.helpers({
postulados (){
return Postulaciones.find();
}
});
}
}
collection.js
my-app / imports / api / postulations / collection.js
imports...
export const Postulaciones = new Mongo.Collection('postulaciones');
Postulaciones.deny({...});
Postulaciones.helpers({
candidato(){
return Candidatos.findOne({_id: this.candidatoId});
}
});
publish.js:
my-app / imports / api / vacancies / server / publish.js
imports...
if (Meteor.isServer) {
Meteor.publishComposite('vacantes.candidatosOseleccionados', function (vacanteId, estado) {
const selector = {$and: [estado, vacanteId]};
return {
find: function () {
return Postulaciones.find(selector);
},
children: [
{
find: function (postulacion) {
return Candidatos.find({_id: postulacion.candidatoId}, {
fields: {
nombre: 1,
apellidos: 1,
sexo: 1,
}
});
}
}
]
};
});
}
Any ideas? - Thanks,