angular material TimePicker ngx-material-timepicker Error Uncaught (in promise): TypeError: Object(...) is not a function

angular material TimePicker ngx-material-timepicker Error Uncaught (in promise): TypeError: Object(...) is not a function

我使用 ngx-material-timepicker timePicker 从 here 安装 使用命令 npm install --save ngx-material-timepicker 我还安装了依赖项 luxon 和 tslib 根据 npm

   import {NgxMaterialTimepickerModule} from 'ngx-material-timepicker';
    @NgModule({
      imports: [NgxMaterialTimepickerModule]
    })

在我的 html 文件中

<input [ngxTimepicker]="picker">
<ngx-material-timepicker #picker></ngx-material-timepicker>

但是错误

core.js:15724 ERROR Error: Uncaught (in promise): TypeError: Object(...) is not a function
TypeError: Object(...) is not a function
    at ngx-material-timepicker.js:231
    at Module../node_modules/ngx-material-timepicker/fesm5/ngx-material-timepicker.js (ngx-material-timepicker.js:238)
    at __webpack_require__ (bootstrap:83)
    at Module../src/app/modules/management/admin/admin.module.ts (admin-routing.module.ts:145)
    at __webpack_require__ (bootstrap:83)
    at $_lazy_route_resource lazy namespace object:34
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:391)
    at Object.onInvoke (core.js:17299)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:390)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:150)
    at resolvePromise (zone.js:831)
    at resolvePromise (zone.js:788)
    at zone.js:892
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
    at Object.onInvokeTask (core.js:17290)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
    at drainMicroTaskQueue (zone.js:601)

基于 github issue and this 您可以使用 "ngx-material-timepicker" 的 3.3.1 版,或者如果您使用的是 angular 8,则可以使用 v4.0.0 版或转到/node_modules/ngx-material-timepicker/fesm5/ngx-material-timepicker.js 并将 ɵɵdefineInjectable 更改为 defineInjectable