Home > database >  I can't get details from a client he gives me [object Object] using angular and firebase
I can't get details from a client he gives me [object Object] using angular and firebase

Time:02-22

I am a beginner in angular firebase, I followed a training, angular firebase, I want details of a client, but it gives me in the client console: [object Object].

list-clients.component.html

<tr *ngFor="let client of clients"> 
  <td >
     <a routerLink="/client/{{ client.id }}" ><i ></i></a>
  </td>
</tr>

client.service.ts

getClient(id:string){
    return this.clientsCollection.doc(id).valueChanges();
  }

details-client.component.ts

ngOnInit(): void {
    this.id = this.route.snapshot.params['id'];
    this.clientService.getClient(this.id).subscribe((client:any) => {
       this.client = client;
       console.log("client est : "   this.client);
     });  
  }

CodePudding user response:

In your example, the this.client property is of type Object. The console.log() method will show you the object properties if you pass the object alone instead of concatenating it to a string. You could also use your debugger and stop execution at the this.client = client line to see the value.

  • Related