0

在我的项目中,我添加了材质角度

ng add @angular/material  

和html代码如下matDatepicker

<div class="form-group row NextDelivery">
                                <label for="NextDelivery"
                                       class="col-sm-3 control-label font-weight-bold mt-1">NextDelivery</label>
                                <div class="col-sm-9">
                                    <mat-form-field color="accent" appearance="fill">
                                    <input matInput  type="text" formControlName="NextDelivery" class="form-control"
                                           id="NextDelivery" matInput [matDatepicker]="picker"  (dateChange)="onMyDateChange($event)"  />
                                           <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
                                           <mat-datepicker #picker touchUi style="position:fixed;"></mat-datepicker>
                                        </mat-form-field>
                                </div>
                            </div>

在 .ts 页面上

导入 { MatDatepickerModule, MatNativeDateModule ,MatFormFieldModule ,MatInputModule ,MatButtonModule } from '@angular/material';

@NgModule({
  imports: [
    
    //Material 
    MatDatepickerModule,       
    MatNativeDateModule,     
    MatFormFieldModule ,
    MatInputModule ,
    MatButtonModule 
  ],
  declarations: [
    SubscriptionsComponent,
    SubscriptionsFormComponent,
    SubscriptionsDetailsComponent,
  ],
})

但日历出现在页面底部,而不是弹出文本框旁边。

日历显示在页面底部

4

0 回答 0