I have this data that I get from API img1, and I need to filter it by rating. I want to store from array only data that have rating more than 2. How we can do this in Angular ?
CodePudding user response:
How to filter data in the controller in angular 4
serviceMethod() {
return http.get(url).pipe(map(response => response.filter(x => x.rating > 2)));
}
componentMethod() {
yourService.serviceMethod().subscribe(results => {
// do something with your list
});
}