角材料样式消失
谁能告诉我我在这里做错了什么?
我有一个物质日期范围的条目,它本身看起来不错。我已经检查了一切,但是我不知所措,因为我看不到这种情况。
<p>Works</p>
<mat-form-field appearance="fill" class="z1">
<mat-label>Enter a date range</mat-label>
<mat-date-range-input [rangePicker]="picker">
<input matStartDate placeholder="Start date" [(ngModel)]="start">
<input matEndDate placeholder="End date" [(ngModel)]="end">
</mat-date-range-input>
<mat-hint>MM/DD/YYYY – MM/DD/YYYY</mat-hint>
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-date-range-picker #picker></mat-date-range-picker>
</mat-form-field>
<button mat-button (click)="search()">Search</button>
<!--<mat-form-field>
<mat-table></mat-table>
</mat-form-field>-->
但是,在有或没有表格字段的情况下,删除了桌子该格式。
<p>Works</p>
<mat-form-field appearance="fill" class="z1">
<mat-label>Enter a date range</mat-label>
<mat-date-range-input [rangePicker]="picker">
<input matStartDate placeholder="Start date" [(ngModel)]="start">
<input matEndDate placeholder="End date" [(ngModel)]="end">
</mat-date-range-input>
<mat-hint>MM/DD/YYYY – MM/DD/YYYY</mat-hint>
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-date-range-picker #picker></mat-date-range-picker>
</mat-form-field>
<button mat-button (click)="search()">Search</button>
<mat-form-field>
<mat-table></mat-table>
</mat-form-field>
供参考,这是我的导入。
@NgModule({
declarations: [
AppComponent,
PrintBookingComponent,
PrintBookingDetailsComponent,
OrderSearchComponent,
OrderBookingComponent,
PageNotFoundComponent,
HomeComponent
],
imports: [
MatDatepickerModule,
MatInputModule,
MatFormFieldModule,
MatNativeDateModule,
MatButtonModule,
MatRippleModule,
BrowserAnimationsModule,
MatMenuModule,
MatTabsModule,
MatTableModule,
MatIconModule,
BrowserModule,
GraphQLModule,
HttpClientModule,
ApolloModule,
FormsModule,
AppRoutingModule,
],
providers: [
{
provide: APOLLO_FLAGS,
useValue: {
useInitialLoading: true, // enable it here
},
},{
provide: APOLLO_OPTIONS,
useFactory: (httpLink: HttpLink) => {
return {
cache: new InMemoryCache(),
link: httpLink.create({
uri: 'http://localhost:3000/graphql/',
}),
};
},
deps: [HttpLink],
}],
bootstrap: [AppComponent]
})
export class AppModule { }
Can anyone tell me what I'm doing wrong here?
I have a material date range entry, and on it's own it looks fine. I have checked everything I can, however I am at a loss as I cannot see any reason for this to be the case.
<p>Works</p>
<mat-form-field appearance="fill" class="z1">
<mat-label>Enter a date range</mat-label>
<mat-date-range-input [rangePicker]="picker">
<input matStartDate placeholder="Start date" [(ngModel)]="start">
<input matEndDate placeholder="End date" [(ngModel)]="end">
</mat-date-range-input>
<mat-hint>MM/DD/YYYY – MM/DD/YYYY</mat-hint>
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-date-range-picker #picker></mat-date-range-picker>
</mat-form-field>
<button mat-button (click)="search()">Search</button>
<!--<mat-form-field>
<mat-table></mat-table>
</mat-form-field>-->
However, uncommenting the table, with or without the form field, removes that formatting.
<p>Works</p>
<mat-form-field appearance="fill" class="z1">
<mat-label>Enter a date range</mat-label>
<mat-date-range-input [rangePicker]="picker">
<input matStartDate placeholder="Start date" [(ngModel)]="start">
<input matEndDate placeholder="End date" [(ngModel)]="end">
</mat-date-range-input>
<mat-hint>MM/DD/YYYY – MM/DD/YYYY</mat-hint>
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-date-range-picker #picker></mat-date-range-picker>
</mat-form-field>
<button mat-button (click)="search()">Search</button>
<mat-form-field>
<mat-table></mat-table>
</mat-form-field>
For reference, this is my imports.
@NgModule({
declarations: [
AppComponent,
PrintBookingComponent,
PrintBookingDetailsComponent,
OrderSearchComponent,
OrderBookingComponent,
PageNotFoundComponent,
HomeComponent
],
imports: [
MatDatepickerModule,
MatInputModule,
MatFormFieldModule,
MatNativeDateModule,
MatButtonModule,
MatRippleModule,
BrowserAnimationsModule,
MatMenuModule,
MatTabsModule,
MatTableModule,
MatIconModule,
BrowserModule,
GraphQLModule,
HttpClientModule,
ApolloModule,
FormsModule,
AppRoutingModule,
],
providers: [
{
provide: APOLLO_FLAGS,
useValue: {
useInitialLoading: true, // enable it here
},
},{
provide: APOLLO_OPTIONS,
useFactory: (httpLink: HttpLink) => {
return {
cache: new InMemoryCache(),
link: httpLink.create({
uri: 'http://localhost:3000/graphql/',
}),
};
},
deps: [HttpLink],
}],
bootstrap: [AppComponent]
})
export class AppModule { }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,不要用
mat-Form-field
包裹,因为MAT-FORM-FIEL
仅与输入,按钮
等的表单一起使用。然后添加dataSource,行,标头,列
类似于下面的代码html:``
``
ts:'
First of all don't wrap with
mat-form-field
becausemat-form-field
work only with form likeinput, button
etc. Then adddataSource, row, header, column
like below codeHTML: `
`
TS:
我已经更新了您的Stackblitz。请检查。
https://stackblitz.com/edit/angular-ivy-hhofab?file=src%2Fapp%2Forder-search%2forder-search%2forder-search.component.h TML,SRC%2FAPP%2Forder-search%2Forder-search.component.ts,src%2FAPP%2Forder-search%2Forder-search.component.scomponent.scss.scss
证据
I have updated your stackblitz . Please check it.
https://stackblitz.com/edit/angular-ivy-hhofab?file=src%2Fapp%2Forder-search%2Forder-search.component.html,src%2Fapp%2Forder-search%2Forder-search.component.ts,src%2Fapp%2Forder-search%2Forder-search.component.scss
Evidence