After attempting to implement this code, I'm running into some issues. It seems like I might be missing a key step.
HTML:
<ng-container *ngFor='let parts of parts$'>
<a class="list-group-item list-group-item-action" (click)="onCategorySelect($event)" value= "parts.Category">{{parts.Category}}</a>
</ng-container>
.TS:
parts$: Parts[];
selectedCategory: Parts[];
constructor(private ApiService:ApiService) { }
ngOnInit() {
return this.ApiService.getParts().subscribe(data => {this.parts$ = data});
}
onCategorySelect($x: any){
this.selectedCategory = this.parts$.filter(element => element.Category === $x.target.value);
}
I am trying to retrieve the specific category that users select from the list.