Within my dataset, I am working with a List of Objects that adhere to the following Model structure:
export class Animal{
public aniId: number;
public aniName: string;
}
export Class Zoo{
public id: number;
public name:string;
public aniId: number;
}
The data includes a list of Zoo
objects which each contain an associated Animal Id
as illustrated below.
[{ "id": 4343, "name": "Canada", "aniId": 1000 }, { "id": 12121, "name": "China", "aniId": 78 }, { "id": 4143, "name": "Russia", "aniId": 58 } ] My inquiry is this: If provided with a list of Animal Objects, what method can I use to retrieve the corresponding Zoos that have these Animals?
For example: If given a list of Animals with Ids 1000 and 58, the expected output would be a list of Zoos with Ids 4343 and 4143.
Note: Although attempted using filters, I encountered difficulties achieving the desired result.
allZoo = this.zooList.filter(x=> x.aniId === this.animalList); <-- Issue here