我在做一个角度计划。我正在尝试使用ngx-数据采集器-材料。我已安装了以下软件包:
npm安装ngx-daterangepicker-材料-节省 npm安装dayjs --保存
我添加了示例代码,如ngx-数据采集器-材料所示。
我的component.ts和component.html的代码如下:
ranges: any = {
'Today': [dayjs(), dayjs()],
'Yesterday': [dayjs().subtract(1, 'days'), dayjs().subtract(1, 'days')],
'Last 7 Days': [dayjs().subtract(6, 'days'), dayjs()],
'Last 30 Days': [dayjs().subtract(29, 'days'), dayjs()],
'This Month': [dayjs().startOf('month'), dayjs().endOf('month')],
'Last Month': [dayjs().subtract(1, 'month').startOf('month'), dayjs().subtract(1, 'month').endOf('month')]
}
model: any;<input type="text" ngxDaterangepickerMd startKey="start" endKey="end" [ranges]="ranges" [(ngModel)]="model">
一旦我运行了服务,我就得到了以下错误:
Error: node_modules/ngx-daterangepicker-material/daterangepicker.component.d.ts:173:9 - error TS2380: The return type of a 'get' accessor must be assignable to its 'set' accessor type
Type 'null' is not assignable to type 'string | Dayjs'.
173 get minDate(): dayjs.Dayjs | null;
~~~~~~~
Error: node_modules/ngx-daterangepicker-material/daterangepicker.component.d.ts:179:9 - error TS2380: The return type of a 'get' accessor must be assignable to its 'set' accessor type
179 get maxDate(): dayjs.Dayjs | null;
~~~~~~~根据上面的错误,从我的代码看似乎不是这样的。它指向node_modules文件夹下的代码。
下面是来自package.json的版本
"dayjs":"^1.11.5“ “ngx-数据采集器-材料”:"^6.0.2",
有人能帮忙解决这个错误吗?
发布于 2022-09-27 15:23:52
根据您对No provider for LocaleService!的评论。
您应该配置必要的提供程序,如下所示.
import { LocaleService } from './locale.service';
.
.
.
.
{ provide: LocaleService, useClass: LocaleService, deps: [LOCALE_CONFIG] },有关更多信息,请单击这里
发布于 2022-09-28 13:17:19
正如@NarenMurali在注释中建议的那样,在compilerOptions of tsconfig.json文件下添加tsconfig.json解决了这个问题。
PS:我遇到了另一个问题,那就是如何获得NullInjectorError。是因为我的模块层次结构。将NgxDaterangepickerMd.forRoot()添加到AppModule下后,该错误将得到解决。
https://stackoverflow.com/questions/73869392
复制相似问题