Within my component.ts
class, I have defined an interface called Country
:
export interface Country{
id: String;
name: String;
checked: false;
}
const country: Country[] = [
{ id: 'India', name: 'India', checked: false},
{ id: 'USA', name: 'USA', checked: false},
{ id: 'Canada', name: 'Canada', checked: false},
]
selectedCountry: Country[] ;
There are checkboxes on the UI for each country. If a user selects India/USA/Canada one at a time, I want to handle it with an if-else
statement like this:
if(this.selectedCountry.includes('India')
// do something;
else if(this.selectedCountry.includes('USA')
// do something;
else ...
However, I encountered an error stating: Argument of type 'string' is not assignable to parameter of type 'Country'.
I would greatly appreciate any pointers or assistance in resolving this issue. Thank you!