ngx-material-timepicker icon indicating copy to clipboard operation
ngx-material-timepicker copied to clipboard

Label on ngx-timepicker-field

Open scottboyd-ai opened this issue 4 years ago • 6 comments

Adding a label to a timepicker-field does not produce the expected output.

With this setup:

<mat-form-field class="form-element">
        <mat-label>Start Time</mat-label>
        <ngx-timepicker-field formControlName="startTime" defaultTime="startTime"></ngx-timepicker-field>
        <input matInput [hidden]="true" formControlName="startTime">
      </mat-form-field>

We see this in the browser: image

The label is located on top of the input fields.

When a value is supplied to the input, the label looks correct: image

With this setup:

 <mat-form-field class="form-element">
        <ngx-timepicker-field label="Start Time" formControlName="startTime" defaultTime="startTime"></ngx-timepicker-field>
        <input matInput [hidden]="true" formControlName="startTime">
      </mat-form-field>

We see this in browser: image

The label does not appear.

scottboyd-ai avatar Nov 02 '21 19:11 scottboyd-ai

I use the following html view and it's rendered fine for me

    <mat-form-field appearance="fill">
      <mat-label for="row-refTime">reference time</mat-label>
      <input id="row-refTime"  matInput [ngxTimepicker]="timepicker" [(ngModel)]="row.refTime">
      <ngx-material-timepicker #timepicker></ngx-material-timepicker>
    </mat-form-field>

giuliohome avatar Nov 02 '21 20:11 giuliohome

That is for the ngx-material-timepicker, not the ngx-timepicker-field.

scottboyd-ai avatar Nov 02 '21 21:11 scottboyd-ai

Sorry for my confusion!

Btw, have you already considered this solution for the label?

giuliohome avatar Nov 02 '21 21:11 giuliohome

I had not! Let me give that a shot and I'll come back with my results.

scottboyd-ai avatar Nov 02 '21 21:11 scottboyd-ai

It's react. We need angular equivalent though. But the design should be the same.

giuliohome avatar Nov 02 '21 21:11 giuliohome

It should be floatLabel="always" in <mat-form-field tag

My example rewritten

<mat-form-field floatLabel="always" appearance="outline" >
  <mat-label for="row-refTime2">reference time</mat-label>
  <input id="row-refTime2"  matInput  [hidden]="true" [(ngModel)]="row.refTime">
  <ngx-timepicker-field  [(ngModel)]="row.refTime"></ngx-timepicker-field>
</mat-form-field>

Screenshot when empty image and with a value entered image

giuliohome avatar Nov 02 '21 21:11 giuliohome