I use set-get in order to detect changes in Angular and pass value from parent to child as shown below:
parent:
<child [employeeId]="empId"></child>
child:
private _employeeIdId: number;
@Input() set employeeIdId(value: number) {
this._employeeIdId = value;
// set dropdown value
}
get employeeIdId(){
return this._employeeIdId;
}
After updating record, I want to pass empId
from parent to child to refresh the table list (refetch again with the same Id). But as this value is already the same, set employeeIdId
does not fired. Any idea how to fix it?
It is known that
ngOnChanges
hook won’t be triggered if the@Input
property’s underlying reference hasn’t changed. While someone else could provide a more elegant solution, here is an inelegant workaround by making the@Input
property an object and forcing reassignment usingJSON.parse(JSON.stringify())
.Parent
Child
Working example: Stackblitz
Note: Since the type definition is changed, the getter to return the
.id
property wouldn’t work. You could use something likegetId()
for it instead.tadalafil generic name – tadalafil generic name tadalafil pills
propecia drug – http://finasteridepls.com/ how long does it take for finasteride to work