vendredi 10 septembre 2021

How to handle this checkbox?

im currently trying to "check" a value in a checkbox if the data from my database is matching. My problem is that my database output comes in a array like this:

(console.log)
[{…}]
0:
fachbetreuung:
betreuer: "DMC\\bianca.nemitz"
bezeichnung: "SCM" //thats the value i need
fachbetreuungId: "72415569-6599-4bf2-a82b-a4124a610f75"
fachbetreuungPersonenzuordnungens: []

So i need the value named "bezeichnung". My problem is now that i need to read every single element of this array and then set the value in my checkbox like this:

this.fachBetreuerType[0].fachbetreuung.bezeichnung

I tried to reach it like that:

<mat-checkbox *ngFor="let bezeichnung of betreuerOverview" 
                        [checked]="fachBetreuerType.fachbetreuung.bezeichnung"> <!-- This is the one-->
                        
</mat-checkbox>

But if i try it like that, angular cant reach the value of the array and logs me "Cannot read properties of undefined (reading 'bezeichnung')". I was thinking about a for loop as a solution but i dont know where i can place it? Into "checked" dont make sense i think.

//EDIT:

this.route.params.subscribe(params => {
      const id = params['id'];
      this.fService
      .getFachInfos(id)
      .subscribe(data => { this.fachBetreuerType = data; console.log(this.fachBetreuerType);
      })}
    )
getFachInfos(fachId:number){
    return this.http.get<FachbetreuungZuordnungSharing[]>(this.fBZ + fachId);
  }

Image of the Content:

https://ibb.co/xGWtLVs




Aucun commentaire:

Enregistrer un commentaire