Scratching my head over this...
I have a function called filterProducts that is called in my Angular 2 component anytime a user clicks a checkbox. For now, the method finds all checkboxes that are checked with a specific class name, gets their values, and then attempts to sort an array. Fairly simple...
// Called when any checkbox is checked or unchecked
filterProducts() {
// Grab all "Program" checkboxes that are checked
var programsToInclude = $(".programCheckbox:checkbox:checked").map(function () { return this.value; });
// If any "Program" checkboxes are checked, filter the list accordingly
if (programsToInclude)
this.filteredProducts = this.filteredProducts.filter(x => programsToInclude.indexOf(x.programName) > -1);
}
Why am I getting the following error?
ORIGINAL EXCEPTION: TypeError: programsToInclude.indexOf is not a function
programsToInclude is definitely a string array, which should have this function, no?