Что я в итоге делаю:
мой .ts код
onChangeStart(event, label) {
console.log("EVENT : " + event);
if (label == 'start_time') {
this.timeStart = event;
}
}
onChangeSeg(event, label, index) {
if (label == 'segmentTime3') {
this.timeSegment = event;
console.log("this.timeSegment : " + this.timeSegment);
}
if (this.timeSegment > this.timeStart) {
console.log(this.timeSegment + " > " +this.timeStart);
}
else {
console.log(this.timeSegment + " < " +this.timeStart);
alert("the segment time is wrong ! The segment time should be later than the start time. ");
}
}
мой .html код
<label for="startTime"> Start time :
<timepicker formControlName="start_time" (ngModel)="start_time" [showMeridian]="isMeridian" [showSpinners]="showSpinners" (ngModelChange)="onChangeStart($event, 'start_time')" #start_time required></timepicker>
</label>
<label for="segmentTime3">Segment time :
<timepicker formControlName="segmentTime3" (ngModel)="segmentTime3" [showMeridian]="isMeridian" [showSpinners]="showSpinners" (ngModelChange)="onChangeSeg($event, 'segmentTime3', i)" #segmentTime3 required></timepicker>
</label>
Возможно, есть лучший вариант, но это работает дляя.