Reputation: 3605
Problem Statement
I am using TypeScript's find()
method for an array, but when I input a value
, it does not work and says, "No overload matches this call".
Code
addOption(event: MatChipInputEvent) {
const input = event.input;
const value = event.value;
// Makes sure that the same element is not inserted in the the options array
if (value !== this.options.find(value)) {
// Add our option
if ((value || '').trim()) {
this.options.push(value.trim());
}
}
// Reset the input value
if (input) {
input.value = '';
}
}
Explanation of Code
As you can see, I am using the find
method in the first if
condition to check and prevent the same element from coming into the array. The value you see there has a red underline and gives me the error, "No overload matches this call". I seem to be doing everything syntactically correct but the error is still there.
Actual Results
The find method gives me the error, "No overload matches this call" and does not accept the value in the parameters.
Expected Results
The find method to take in the value and find the element in the array.
Upvotes: 0
Views: 1301