Hi there, I'm new to this forum so if I break any rules, please let me know!
I'm working with the code below in my app.component.html:
<tr *ngFor="let item of items" (click)="getClient($event)">
<td> {{ item.nr }} </td>
<td> {{ item.content }} </td>
</tr>
In my app.component.ts, I am fetching data from an API:
export class AuftragslisteComponent implements OnInit {
constructor(public http: HttpClient) { }
getItem() {
return this.http.get("http://localhost:59643/api/lösa");
}
items: Object;
ngOnInit() {
this.getItem().subscribe(data => {
this.items = data;
console.log(this.items);
console.log(data);
})
}
getClient() {
}
}
I'm trying to access the item.nr by clicking a row, but the value always comes up as undefined when using the alert function in the getClient method, so I removed it.
Does anyone have any tips on how to correctly access the item.nr by clicking a row?