找不到名称"MAT_DATE_LOCALE";与Material.angular日期选择器 [英] Cannot find name "MAT_DATE_LOCALE" with Material.angular Datepicker

查看:178
本文介绍了找不到名称"MAT_DATE_LOCALE";与Material.angular日期选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据文档 https://material.angular.io/components/datepicker/overview 此处将

设置为您要提供的语言环境代码

 提供者:[{提供:MAT_DATE_LOCALE,useValue:'en-GB'},] 

但是我的应用程序无法编译,因为它告诉我它找不到名称MAT_DATE_LOCALE.我是否在这里缺少某些东西,因为我必须自己定义?但是,我无法想到将其放置在什么位置,因为所有这些都在模块类中.

解决方案

在Angular 9中执行导入:

  {MAT_DATE_LOCALE}来自"@ angular/material/core"; 

我想必须在导入中输入指定的路径导入.优化的东西.

对不起,我的英语.

从Angular 9中,无法通过@ angular/material导入任何组件.您将使用单独的辅助入口点,例如@ angular/material/button.

Angular 9的主要新功能

According to the documentation https://material.angular.io/components/datepicker/overview here to set the locale code to one you want you provide it by putting

providers: [
    {provide: MAT_DATE_LOCALE, useValue: 'en-GB'},
]

But then my app won't compile as it tells me it cannot find the name MAT_DATE_LOCALE. Am I missing something here as in I have to define it myself? Though, I can't think of where to put it as it's all in the module class.

解决方案

In Angular 9 do the import:

 { MAT_DATE_LOCALE } from '@angular/material/core';

I suppose that in the import must be entered specified path import. Optimization stuff.

Sorry for my english.

From Angular 9, no component can be imported through @angular/material. You are to use the individual secondary entry-points, such as @angular/material/button.

Top New Features of Angular 9

这篇关于找不到名称"MAT_DATE_LOCALE";与Material.angular日期选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆