I'm trying to get a result of search. i used filter function but I got a error
HomeComponent.html:13 ERROR TypeError: Cannot read property 'toLowerCase' of undefined
My components.html
<div class="row">
<input type="text" class="form-control" placeholder="search" (input)="filter($event.target.value)">
Mycomponents.ts
filter(keyWord: string) {
if (keyWord === undefined || keyWord.length === 0) {
this.findAllArticles();
return;
}
this.article = this.article.filter(article =>
article.category.toLowerCase().includes(keyWord.toLowerCase()) || article.designation.toLowerCase().includes(keyWord.toLowerCase())
);
}
Thanks
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…