Hello, thanks for read
When running helper
brings values are stored in the variable verCandidatos.postulados
.
Once I get me the information I need to get a document that is linked (using the function ng-init="candidato = la postulado.candidato()
) wich runs on the helper
from file: collection.js
.
Sometimes the html
shows the properties: {{candidato.nombre}}
, {{candidato.apellidos}}
and {{candidato.sexo}}
correctly, and sometimes appear empty, why?
Is very strange, like a bug
or something. How is possible that behavior?
The information is being obtained, because the ng-repeat
works and shows elements.
Below is the publishComposite(), collection.js, html
and js
client
html client
**my-app/imports/ui/components/vacantes/verCandidatos/**verCandidatos.html
<div ng-repeat="postulado in verCandidatos.postulados">
<div ng-init="candidato = postulado.candidato();">
{{candidato.nombre}}
{{candidato.apellidos}}
{{candidato.sexo}}
</div>
</div>
js in client
**my-app/imports/ui\components/vacantes/verCandidatos/**verCandidatos.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/postulaciones/**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/vacantes/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,