How can I refactor this code using angular 2 methods? I could not find anything on google.
var tooltipsData = $.grep(tooltips, function (element, index) {
return (element.ProductCode == ProductCode);
});
Looks like what you really are trying to do is implement that without jQuery (Angular 2 is still just JavaScript (or TypeScript)). If you are trying to implement it in JS, use the Array.filter function
var tooltipsData = tooltips.filter(function (element, index) {
return (element.ProductCode === ProductCode);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With