export class MyModel { trnMinDate: string | null = null; trnMaxDate: string | null = null; get trnMinimumDate(): Date | null{ if (!this.trnMinDate) return null return new Date(this.trnMinDate); } get trnMaximumDate(): Date | null { if (!this.trnMaxDate) return null return new Date(this.trnMaxDate); } } This is my modal class for the angular project. I am fetching data from an API and assigning the values for trnMinDate and trnMaxDate. my app.component.ts file is in the following content. export class AppComponent implements OnInit{ minDate: Date; maxDate: Date; ngOnInit() { const fetchDataFromApi$ = this._myService.getData(); fetchDataFromApi$.subscribe({ next: (data: MyModel ) => { console.log('min-trn-date',data.trnMinDate)//value is logging console.log('max-trn-date',data.trnMaxDate)//value is logging this.minDate=data.trnMinimumDate; this.maxDate=data.trnMaximumDate; console.log('min-date-value',this.minDate)//value is logging as undefined console.log('max-date-value',this.maxDate)//value is logging as undefined }, error: (error) => { } }) } } When I log it(min-date-value & max-date-value) like this, both values are logged as undefined, but trnMinDate and trnMaxDate have string values. How can I find the issue? Continue reading...