简体   繁体   English

无法绑定到“matDatepicker”,因为它不是“div”的已知属性 - Angular

[英]Can't bind to 'matDatepicker' since it isn't a known property of 'div' - Angular

I am trying to show datepicker, instead of input element I used div tag because just I need to show selected date as a label.我试图显示日期选择器,而不是使用 div 标签的输入元素,因为我只需要将所选日期显示为 label。 Below is my code.下面是我的代码。

         <mat-form-field>
         <!-- <input matInput [matDatepicker]="picker" placeholder="choose a Date" (click)="picker.open()"> -->
        <div matInput [matDatepicker]="picker"  (click)="picker.open()"></div>
        <mat-datepicker #picker></mat-datepicker>
        </mat-form-field>

app.module.ts app.module.ts

        import { MatDatepickerModule } from '@angular/material/datepicker';
        import { MatNativeDateModule } from '@angular/material/core';
       @NgModule({
         imports: [
          ...
          MatDatepickerModule,
          MatNativeDateModule
         ]

But I am getting below error, when I run my application,但是当我运行我的应用程序时,我遇到了错误,

Error: Template parse errors: Can't bind to 'matDatepicker' since it isn't a known property of 'div'.错误:模板解析错误:无法绑定到“matDatepicker”,因为它不是“div”的已知属性。

You can use the input and make it readonly: [readonly]="true" .您可以使用输入并将其设为只读: [readonly]="true"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法绑定到“ useStickyClasses”,因为它不是“ div”的已知属性 - Can't bind to 'useStickyClasses' since it isn't a known property of 'div' Angular 7:无法绑定到“元素”,因为它不是 - Angular 7 : Can't bind to 'element' since it isn't a known property of 无法绑定到“”,因为它不是“ angular 2”的已知属性 - can't bind to '' since it isn't a known property of '' angular 2 Angular 6 日历模板解析错误:无法绑定到“视图”,因为它不是“div”的已知属性 - Angular 6 Calendar Template parse errors: Can't bind to 'view' since it isn't a known property of 'div' 在控制台中出现错误无法绑定到“ngif”,因为它不是 angular 应用程序中“div”的已知属性 - Getting error in console Can't bind to 'ngif' since it isn't a known property of 'div' in angular app 带有 Angular 的 NG2 图表:无法绑定到“颜色”,因为它不是 Angular 中“画布”的已知属性 13 - NG2 Chart with Angular: Can't bind to 'colors' since it isn't a known property of 'canvas' in Angular 13 无法绑定到“控件”,因为它不是(myComponent)的已知属性 - Can't bind to 'control' since it isn't a known property of (myComponent) 无法绑定到“matMenuTrigger”,因为它不是“a”的已知属性 - Can't bind to 'matMenuTrigger' since it isn't a known property of 'a' 无法绑定到“ngModel”,因为它不是“输入”的已知属性 - Can't bind to 'ngModel' since it isn't a known property of 'input' 无法绑定到“数据集”,因为它不是“画布”的已知属性 - Can't bind to 'datasets' since it isn't a known property of 'canvas'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM