datepicker.component.ts 679 B

12345678910111213141516171819202122232425
  1. import { Component } from '@angular/core';
  2. import { NativeInputComponent } from '../../_abstract/native-input.component';
  3. @Component({
  4. selector: 'app-datepicker',
  5. templateUrl: './datepicker.component.html',
  6. styleUrls: ['./datepicker.component.scss']
  7. })
  8. export class ClrDatepickerComponent extends NativeInputComponent {
  9. exposeMetaInTemplate: string[] = ['extraClass', 'placeholder'];
  10. ngOnInit() {
  11. super.ngOnInit();
  12. // CLarity datepicker expects a string when used reactively
  13. const dateObj = this.control.value;
  14. const d = dateObj.getDate();
  15. const m = dateObj.getMonth();
  16. const y = dateObj.getFullYear();
  17. this.control.setValue(`${d}/${m + 1}/${y}`);
  18. }
  19. }