Angular 2-Filtering table based on select dropdown (both are different components)

forgottofly picture forgottofly · Sep 7, 2017 · Viewed 9.5k times · Source

I'm trying to filter data table component based on the value passed by select drop down component.I'm using @Input() attribute but the selected dropdown data is not been passed to data table component. If it is passed I will be able to filter table using the below logic:

Not sure where I'm doing wrong here.

onChangeDetected(val){ 
  this.someData= this.someData.filter(x => x.value== val)
}

Full implementation can be found here

Answer

user4676340 picture user4676340 · Sep 7, 2017

I've corrected your problem in this plunker. Now the data is passed and the data changes according to your selected value.

Feel free to look around and look for explanation on Angular's website.

// Mandatory code with plunkr