I\'ve a component that takes function as input. I\'ve passed this function from parent.
Though the function is called, the function is not able to access the depende
You can pass a get/set property instead of a function in a similar way like that:
Somewhere in your view:
In your component file:
@Component({
selector: 'myapp',
templateUrl: './myapp.component.html',
styleUrls: ['./myapp.component.scss']
})
export class App {
constructor() { }
yourprop: any;
get yourprop(): any {
return this.scheduleEndDate;
};
//set accessor including call the onchange callback
set yourprop(v: any) {
// TODO do something else
// You can do whatever you want just like you have passed a function
if (v !== this.scheduleEndDate) {
this.scheduleEndDate = v;
}
}
}
more info @ https://almerosteyn.com/2016/04/linkup-custom-control-to-ngcontrol-ngmodel