I have this component:
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-workers-edit',
templateUrl: './workers-edit.component.html',
styleUrls: ['./workers-edit.component.css']
})
export class WorkersEditComponent implements OnInit {
public workerid;
public lastname;
public address;
public phone;
public email;
workers = [];
constructor(private route: ActivatedRoute, private http: HttpClient) { }
ngOnInit() {
let id = parseInt(this.route.snapshot.paramMap.get('id'));
this.workerid = id;
let Workerobs = this.http.get('http://myurlPP/cfcs/workernameapi.cfm');
Workerobs.subscribe((res:any)=> {
console.log(res);
this.workers = res;
});
}
}
The workers array after this contains the following:

In my html, if I do this:
<ul>
<li *ngFor="let name of workers">{{name.WNAME}}</li>
</ul>
I will get all the names from the array and display them, which is okay.
But I need to display only the name with the matching workerid. (I have the workerid at because of let id = parseInt(this.route.snapshot.paramMap.get('id')); this.workerid = id;
So how can I extract from the workers array the WID, compare it to workerid, if it is true, display only the WNAME (worker name) ?