I'm trying to access data from an input to a component, and using ngOnChanges to do so, but VS code complains that the input I'm trying to grab isn't a property of the SimpleChanges object, and thus doesn't compile. What am I doing wrong here?
@Input('filters') filtersInput;
ngOnChanges(changes: SimpleChanges) {
console.log(changes);
this.filters = changes.filtersInput.currentValue;
}
I get that filtersInput isn't a part of SimpleChanges, but as that's the class, it makes sense?
It was just a compilation-time error because the interface of SimpleChanges doesn't have filtersInput property explicitly:
export interface SimpleChanges {
[propName: string]: SimpleChange;
}
You will have to get the value by using indexer instead:
this.filters = changes["filtersInput"].currentValue;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With