According to your example would be better like this
app.component.html
<input
type="text"
id="myInput"
(keyup)="search($event.target)"
placeholder="Search for product.."
title="Type in a name"
/>
<ul id="myProduct" *ngFor="let product of filteredProducts">
<li>
<a href="#">{{ product.name }}</a>
</li>
</ul>
app.component.ts
import { Component, OnInit, VERSION } from '@angular/core';
import { Product } from './product';
import { ProductGroup } from './product-group';
import { ProductService } from './services/product.service';
// import * as var from 'jquery';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent implements OnInit {
constructor(private productService: ProductService) {}
product: Product[];
productGroup: ProductGroup[];
availableProducts: Product[];
filteredProducts: Product[];
search(e) {
this.filteredProducts = this.availableProducts.filter(
(p) => p.name.toUpperCase().indexOf(e.value.toUpperCase()) > -1
);
}
getProduct() {
this.productService.getProductsSmall().then((products) => {
this.availableProducts = products;
this.filteredProducts = products;
});
}
ngOnInit() {
this.getProduct();
}
}