如何选择用户输入的日期和时间?我需要使用Angular将其保存在firestore时间戳属性中。请给我一种方法。
答案 0 :(得分:0)
您可以使用npm的Angular Date Time Picker软件包从输入中获取日期和时间。
示例代码
1)module.ts
import { OwlDateTimeModule, OwlNativeDateTimeModule } from 'ng-pick-datetime';
@NgModule({
declarations: [],
imports: [
OwlDateTimeModule,
OwlNativeDateTimeModule
],
})
2)component.html
<input type="text" placeholder="MM/DD/YYYY" [owlDateTime]="dt1"
formControlName="installDate" id="installDate" autocomplete="off"
(ngModelChange)="onInstallDateChange()" class="form-control"
[max]="currentDate" />
<owl-date-time #dt1 pickerType="calendar"></owl-date-time>
3)component.ts
onInstallDateChange() {
// Your code
}
答案 1 :(得分:0)
../../ node_modules / ng-pick-datetime / date-time / date-time-picker.component.d.ts:2:62中的错误-错误TS2307:找不到模块'@ angular / cdk /覆盖'。
2从'@ angular / cdk / overlay'导入{BlockScrollStrategy,Overlay,ScrollStrategy}; ~~~~~~~~~~~~~~~~~~~~~~ ../../node_modules/ng-pick-datetime/dialog/dialog-config.class.d.ts:2:32-错误TS2307:找不到模块'@ angular / cdk / overlay'。
2从'@ angular / cdk / overlay'导入{ScrollStrategy}; ~~~~~~~~~~~~~~~~~~~~~~ ../../node_modules/ng-pick-datetime/dialog/dialog-container.component.d.ts:3:34-错误TS2307:找不到模块'@ angular / cdk / a11y'。
3从'@ angular / cdk / a11y'导入{FocusTrapFactory}; ~~~~~~~~~~~~~~~~~~~ ../../node_modules/ng-pick-datetime/dialog/dialog-container.component.d.ts:4:84-错误TS2307:找不到模块'@ angular / cdk / portal'。
4从'@ angular / cdk / portal'导入{BasePortalOutlet,CdkPortalOutlet,ComponentPortal,TemplatePortal}; ~~~~~~~~~~~~~~~~~~~~~ ../../node_modules/ng-pick-datetime/dialog/dialog-ref.class.d.ts:2:28-错误TS2307:找不到模块'@ angular / cdk / overlay'。
2从'@ angular / cdk / overlay'导入{OverlayRef}; ~~~~~~~~~~~~~~~~~~~~~~ ../../node_modules/ng-pick-datetime/dialog/dialog.service.d.ts:6:59-错误TS2307:找不到模块'@ angular / cdk / overlay'。
6从'@ angular / cdk / overlay'导入{Overlay,OverlayContainer,ScrollStrategy}; ~~~~~~~~~~~~~~~~~~~~~~ ../../node_modules/ng-pick-datetime/dialog/dialog.service.d.ts:7:31-错误TS2307:找不到模块'@ angular / cdk / portal'。
7从'@ angular / cdk / portal'导入{ComponentType}; ~~~~~~~~~~~~~~~~~~~~
** Angular Live Development Server正在localhost:4200上侦听,请在http://localhost:4200/上打开浏览器** 我「wdm」:无法编译。