1

We have two classes "demande" and "entreprise" with a relation OneToMany. I would like to show every demande's entreprise.

The API works but the problem is on the front.

The entreprise's service :

getDemandeEntreprisebyId(id)
  {
    this.http.get(this.rootURL + '/Entreprise/EntrepriseByDemande/'+id)
    .toPromise()
    .then(res => this.listDemandeEntreprise = res as Entreprise[]);
  }

View :

<tr *ngFor="let sd of serviceDemande.list" >
  <td (click)="populateForm(pd)">{{pd.dateDemande | date : 'dd/MM/yyyy'}}</td>
  <td (click)="populateForm(pd)">{{pd.typeDemande}}</td>                                                                                                                                                                                                                                                                                                                                                                                                                                          
  <td  *ngFor="let e of serviceEntreprise.getDemandeEntreprisebyId(sd.idDemande)">{{e.nomEntreprise}}</td>
</tr>
C.OG
  • 6,236
  • 3
  • 20
  • 38
  • 1
    You need to return the data from the service (i.e., `return this.http.get`...). – Heretic Monkey Apr 17 '19 at 15:00
  • @HereticMonkey I'm novice, I have not understand your explication. Can you explain more please ? Thank you – Pierre Laurent Apr 17 '19 at 15:08
  • 1
    Put your cursor in front of the first letter after the `{` in the `getDemandeEnterprisebyId` function. Type `return` and a space. See [MDN's documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return). – Heretic Monkey Apr 17 '19 at 15:17
  • what are you getting in the sd.idDemande ?. have you checked the value with the debugger or using console.log? in getDemandeEntreprisebyId function ? – zetawars Jan 01 '20 at 15:55

0 Answers0