I have an Angular2 Directive which sets the maxDate of my DatePicker like this.
@Directive({ selector: '[maxDate]' }) export class MaxDateDirective { private domElement: any; @Input() set maxDate(max: any) { if (max) { $(this.domElement).data("DateTimePicker").maxDate(max); } } constructor(private element: ElementRef, private renderer: Renderer) { this.domElement = element.nativeElement; } } In my component I've dateFrom and dateTo like this.
<div class="col-md-3"> <div class="form-group"> <label class="label-control">{{'START_DATE' | translate}}</label> <input id="owner_start_date" name="owner_start_date" type="text" class="form-control datepicker" [(ngModel)]="filters.lastWeek" [maxDate]="filters.today" /> </div> </div> <div class="col-md-3"> <div class="form-group"> <label class="label-control">{{'END_DATE' | translate}}</label> <input id="owner_end_date" name="owner_end_date" type="text" class="form-control datepicker" [(ngModel)]="filters.today" /> </div> </div> So, my fromDate picker has this [maxDate]="filters.today", which is bind to the [(ngModel)]="filters.today" of the toDate picker, but my @Input() set maxDate(max: any)is only triggering once. How can I check for updates on the model in the component from inside the Directive? I don't want to add code to the component, the Directive should be in charge of that logic, like the $watch in Angular1.