I emit an event and i want to receive the number that my event gives here’s my code:
here’s is where i emit my event, which is right
editarProcesso(id){
this.navCtrl.push(HomePage, {id : id})
.then(() => {
this.events.publish('id:added', id)
});
return console.log('id: ',id);
}
Finally here’s where i get and aplly it:
this.model = new Processos();
let idGenerator = this.events.subscribe('id:added', (id) => {
console.log('Generator' ,id)
})
if(idGenerator != null){
this.processoProvider.getcamposProcesso(idGenerator)
.then((result : any) =>{
this.model = result;
return console.log(idGenerator);
}).catch((e) => console.log('Erro ao carregar os campos', e))
}
}
Problem log: [ts] Argument of type ‘void’ is not assignable to parameter of type ‘number’.
let idGenerator: void
The problem is the variable idGenerator receives a value null, and I and want to get value id, which is number???
Thanks in advance!