Scenario: I am developing a time picker component for Angular 2. I need to pass values from Angular 2 Components to the jQuery timepicker in order to set parameters like minTime and maxTime.
Below is the code snippet:
export class TimePicker{
@Input() minTime : string;
@Input() maxTime : string;
@ViewChild('timePicker') tmElement : ElementRef;
ngAfterViewInit(){
$(this.tmElement.nativeElement).timepicker({
timeFormat: 'h:mm p',
minTime: '11', --> Need this.minTime ??
maxTime: '6:00pm', --> Need this.maxTime ??
dynamic: false,
dropdown: true,
scrollbar: true,
change: (time)=> {
this.changedTime(time);
}
});
}
changedTime(time : Date){
// This method is easily called due to fat arrow
}
I have attempted using the bind method without success. Since I plan on utilizing jQuery sporadically, this implementation will be beneficial in the long run. Thank you :)