I would like to show the data of object but I get error
My service
getUSers(path: string) {
return this.db.list(this.PATH + path)
.snapshotChanges()
.map(changes => {
return changes.map(c => ( {key: c.key , ...c.payload.val() } ));
})
}
Now in my list user I have a method to navigate go details user page but I get erro
getLawyers() {
this.service.getUSers('lawyers')
.subscribe(
result => this.lawyers = result
)
}
selectedLawyer(lawyer) {
this.navCtrl.push('DetailsLawyerPage', {
lawyer: lawyer
})
}
In my details page I’m trying get the values and shot in page deitailscomponent.ts
lawyer: Observable<any[]>;
constructor(public navCtrl: NavController, public navParams: NavParams, public modalCtrl: ModalController) {
this.lawyer = this.navParams.get('lawyer');
}
details.html
<ion-card-content>
<ion-item>{{ lawyer.name }}</ion-item>
<ion-item>N° OAB - {{ lawyer.noab }}</ion-item>
<ion-item>Especialidade - {{ lawyer.specialty.name }}</ion-item>
<ion-item>Especialidade - {{ lawyer.specialties.name }}</ion-item>
<ion-item>Email - {{ lawyer.email }}</ion-item>
<ion-item>Estado - PA</ion-item>
<ion-item>Cidade - {{ lawyer }}</ion-item>
<div>{{ (lawyer.reputation | async) }} Likes</div>
</ion-card-content>
so I get this erro any ideia friends ?
I guess the lawyer object you are sending to your detailscomponent.ts is no Observable. That’s what the error says: You are using the async pipe on a simple object!
Either remove the async pipe or make sure that the lawyer you pass is an actual Observable. Right now I don’t know how your HTML looks that is calling selectedLawyer() so it’s hard to say what you are sending to the Page!
I did so @saimon
<ion-item>{{ lawyer?.name }}</ion-item>
and works but now a bigger question how to get this value
specialty { key: xx, name: example } in the same object ?
How does your object look like in JSON? And what code are you currently using to unwrap it? I’m sure we can easily spot the issue here
Is true my friend I forgot of comment that I get this date of services
getUsers(path: string) {
return this.db.list(this.PATH + path)
.snapshotChanges()
.map(changes => {
return changes.map(c => ( {key: c.key , ...c.payload.val() } ));
})
}
In my list component I have
getLawyers() {
this.service.getUsers('lawyers')
.subscribe(
result => this.lawyers = result
)
}
selectedLawyer(lawyer) {
this.navCtrl.push('DetailsLawyerPage', {
lawyer: lawyer
})
}
I am sending to next page detailscomponent the dates through nactrl and in my details I get this object so
lawyer: any[];
state: any;
constructor( public navParams: NavParams) {
this.lawyer = this.navParams.get('lawyer');
}
and tho show in html
<ion-card-content>
<ion-item>{{ lawyer?.name }}</ion-item>
<ion-item>{{ lawyer?.email }}</ion-item>
<ion-item>N° OAB - {{ lawyer?.noab }}</ion-item>
<ion-item>Especialidade - {{ lawyer?.specialty }}</ion-item>
<ion-item>Especialidade - {{ lawyer?.specialties }}</ion-item>
<ion-item>Estado - {{ state }}</ion-item>
<ion-item>Cidade - {{ lawyer?.city }}</ion-item>
</ion-card-content>