1
0
Fork 0

Fix: date selector

This commit is contained in:
Aroy-Art 2025-05-15 16:04:56 +02:00
parent 6f88f96de8
commit 74b0d4d70c
Signed by: Aroy
GPG key ID: DB9689E9391DD156
2 changed files with 14 additions and 5 deletions

View file

@ -20,8 +20,8 @@
<input <input
type="date" type="date"
id="date" id="date"
[ngModel]="selectedDate | date:'yyyy-MM-dd'" [value]="formattedDate"
(ngModelChange)="onDateChange($event)" (change)="onDateChange($event)"
[max]="maxDate"> [max]="maxDate">
</div> </div>
</div> </div>
@ -67,3 +67,4 @@
</table> </table>
</div> </div>
} }
</div>

View file

@ -58,13 +58,21 @@ export class AppComponent implements OnInit {
this.loadPriceData(); this.loadPriceData();
} }
onDateChange(event: any) { onDateChange(event: Event) {
this.selectedDate = new Date(event.target.value); // Fix: properly handle date input event
this.loadPriceData(); const inputElement = event.target as HTMLInputElement;
if (inputElement.value) {
this.selectedDate = new Date(inputElement.value);
this.loadPriceData();
}
} }
get maxDate(): string { get maxDate(): string {
const today = new Date(); const today = new Date();
return today.toISOString().split('T')[0]; return today.toISOString().split('T')[0];
} }
get formattedDate(): string {
return this.selectedDate.toISOString().split('T')[0];
}
} }