我已经编写了一个 mat-date-picker,并希望从我的 JSON 中输出来自 accountingYearStart 的值。我写了以下代码:
<div class="form-group" id="align-date-picker">
<mat-form-field appearance="fill" id="optimize-form-field">
<mat-label>Datum</mat-label>
<label>
<input matInput [matDatepicker]="picker" formControlName="fiscalYearStart" required>
</label>
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
</div>
ngOnInit() {
// To initialize loadData
this.loadData();
}
// Fill the dashboard with data
loadData() {
this.userAreaService.getCurrentFiscalYear().subscribe( resp => {
const fiscalYearStart = resp.success ? resp.mandant.fiscalYearStart : null;
return fiscalYearStart;
});
}
// JSON
{
"success": true,
"mandant": {
"mandantId": 1,
"firm": "Test1",
"landLineNumber": "+658978784344",
"fiscalYearStart": "Dez. 6, 2020" // I want to output this
}
}