I am trying to trigger a click
event for each element based on its id
, but it doesn't seem to be working.
Below is the code I am using:
ngOnInit() {
this.getProductsLists();
}
getProductsLists() {
this.supplierService.getProductLists()
.subscribe(data => {
this.productData = data;
this.productData.forEach((value) => {
value.prodCategoryChild.forEach((element) => {
$('#prod' + element.id).click(() => {
alert('This is not working');
})
});
});
});
}
Can anyone please point out what may be missing in my approach? Any help would be greatly appreciated. Thank you!