Нужна помощь относительно моей проблемы с форматом даты. У меня есть поле даты со значением 03/14/2020
в angular, оно форматируется с использованием канала даты (исходное значение 2020-03-14T21:38:35
), однако после сохранения мое поле даты снова стало форматом 2020-03-14T21:38:35
.
Я использую реактивные формы в моих angular приложениях. Пожалуйста, смотрите ниже код
ngOnInit() {
this.tenantId = this.localStorageService.getTenantId();
this.tenantCode = this.localStorageService.getTenantCode();
const id = this.route.snapshot.paramMap.get('id');
this.editMode = this.id != null;
if (!this.editMode) {
this.subsink.sink = this.journalEntryService.getJournalEntryByIdAndTenantId(id, this.tenantId).subscribe(_journalEntry => {
if (_journalEntry) {
this.journalEntry = _journalEntry;
this.journalEntryForm = this.formBuilder.group({
id: [this.journalEntry.id],
accountingCalendarPeriodId: [this.journalEntry.accountingCalendarPeriodId, Validators.required],
journalCategoryId: [this.journalEntry.journalCategoryId, Validators.required],
journalBalanceId: [this.journalEntry.journalBalanceId, Validators.required],
currencyId: [this.journalEntry.currencyId, Validators.required],
journalEntryName: [this.journalEntry.journalEntryName, Validators.required],
journalDateCreated: [{ value: this.datePipe.transform(this.journalEntry.journalDateCreated, 'MM/dd/yyyy'), disabled: true }],
journalTypeName: [{ value: this.journalEntry.journalTypeName, disabled: true }],
referenceName: [{ value: this.journalEntry.referenceName, disabled: true }],
journalPosted: [{ value: this.journalEntry.journalPosted ? 'Posted' : 'Unposted', disabled: true }],
journalDatePosted: [{value: this.journalEntry.journalDatePosted, disabled: true}],
currencyRate: [{value: this.decimalPipe.transform(this.journalEntry.currencyRate, '1.2-2'), disabled: true }],
postingReference: [{
value: this.journalEntry.postingReference ? this.journalEntry.postingReference : '',
disabled: true
}],
journalDescription: [this.journalEntry.journalDescription, [Validators.required]],
journalEnteredTotalDr: [{value: this.journalEntry.journalEnteredTotalDr, disabled: true }],
journalEnteredTotalCr: [{value: this.journalEntry.journalEnteredTotalCr, disabled: true }],
journalEnteredBalance: [{value: this.journalEntry.journalEnteredBalance, disabled: true}],
active: [{ value: this.journalEntry.active ? 'Yes' : 'No', disabled: true }],
journalEntryDetail: this.formBuilder.array([])
});
this.getJournalEntryDetails(this.journalEntry);
console.log(this.journalEntry);
} else {
this.onAddJournalEntryLine();
}
});
}
this.getSetOfBooks(this.tenantId);
this.getFlexFieldCombinationByTenantId(this.tenantId);
this.getJournalCategoryByTenantId(this.tenantId);
this.getJournalBalanceTypeByTenantId(this.tenantId);
this.getCurrencyByTenantId(this.tenantId);
this.enteredTotalDrCrValueChanges$ = this.journalEntryForm.controls['journalEntryDetail'].valueChanges;
this.enteredTotalDrCrValueChanges$.subscribe(_journalEntryDetail => {
if (_journalEntryDetail) {
this.updateTotalEnteredAmount(_journalEntryDetail);
}
});
}