When working in my angular-7 class and using jQuery, I encountered a problem where I needed to store all text from h4 tags in an array. However, the issue was that when using this, it would only refer to Angular's version of this rather than jQuery's. Despite attempting to use the fat arrow function, I still couldn't get it to work as intended.
I also experimented with callback parameters in hopes of accessing the elements, but they continued to remain undefined.
Below is the code snippet I've been struggling with. Any suggestions or help would be greatly appreciated.
Thank you.
$('h4').each((idx, elem) => {
this.listItems.push({ id: idx, text: elem.innerText });
});