Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////////////// Component HTML //////////////////////////
- <form [formGroup]="dataSearch">
- <mat-form-field fxShow fxHide.lt-lg style="width: 250px;">
- <mat-label for='calendar-input'>{{ "NAV.RANGEDATA" | translate }}</mat-label>
- <input type="text" id="calendar-input" matInput ngxDaterangepickerMd [locale]="locale"
- [showDropdowns]="true" [showClearButton]="true" showCancel="true" formControlName='data'
- readonly />
- <mat-icon class="ngx-daterangepicker-action" matSuffix (click)="openCalendar()">
- calendar_today</mat-icon>
- </mat-form-field>
- </form>
- //////////////////////////////// Component ts ////////////////////////////////////////////////////
- dataInizio:string;
- dataFine:string;
- dataSearch:FormGroup;
- locale:LocaleConfig = {
- format:'YYYY-MM-DD',
- displayFormat:'DD-MM-YYYY',
- cancelLabel: 'Close', // detault is 'Cancel'
- applyLabel: 'Ok', // detault is 'Apply'
- clearLabel: 'Clear', // detault is 'Clear'
- }
- @ViewChild(DaterangepickerDirective, {static:false}) picker:DaterangepickerDirective;
- ngOninit() : void{
- this.dataInizio = moment().format("YYYY-MM-DD");
- this.dataFine = moment().subtract(10, 'days').format("YYYY-MM-DD");
- this.dataSearch = new FormGroup({
- data:new FormControl(`${this.dataInizio} - ${this.dataFine}`) // anche se inserisco questo oggetto
- }); // {startDate:"26-01-2021, endDate:"01-01-2021"}
- // restituisce sempre il primo valore
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement