我的表单中有2个日期输入,如下所示:
<label class="control-label">Start Date</label>
<input type="date" name="startDate" placeholder="Start Date" class="form-control" ngModel required #startDate="ngModel">
<span *ngIf="!startDate.valid && startDate.touched" class="error-msg">
<span *ngIf="startDate.errors.required">Start Date is required</span>
</span>
<br/>
<label class="control-label">End Date</label>
<input type="date" name="endDate" placeholder="End Date" class="form-control" ngModel required #endDate="ngModel" >
<span *ngIf="!endDate.valid && endDate.touched" class="error-msg">
<span *ngIf="endDate.errors.required">End Date is required</span>
</span>
我想让用户只选择开始日期的日期。我尝试使用min
属性但无法正常工作
答案 0 :(得分:1)
您可以使用min
属性
<label class="control-label">End Date</label>
<input type="date" name="endDate" placeholder="End Date" class="form-control" ngModel required #endDate="ngModel" min="{{your_form_name.value.startDate}}">