Witam,
Mam taką klasę:
export class InstitutionFilter {
sort:{
direction: string;
field: string;
};
limit: number;
search: string;
}
Podczas próby inicjalizacji lub odczytu pól 'direction' lub 'field' np.
institutionFilter = new InstitutionFilter();
this.institutionFilter.sort.direction = 'asc';
this.institutionFilter.sort.field = 'name';
this.institutionFilter.limit = 25;
this.institutionFilter.search = '';
Otrzymuję błąd
error_handler.js:51 Error: Uncaught (in promise): TypeError: Cannot set property 'direction' of undefined
at resolvePromise (http://localhost:3000/index.js:49668:31)
at http://localhost:3000/index.js:49645:13
at ZoneDelegate.invoke (http://localhost:3000/index.js:49442:28)
at Object.onInvoke (http://localhost:3000/index.js:59735:37)
at ZoneDelegate.invoke (http://localhost:3000/index.js:49441:34)
at Zone.run (http://localhost:3000/index.js:49335:43)
at http://localhost:3000/index.js:49701:57
at ZoneDelegate.invokeTask (http://localhost:3000/index.js:49475:37)
at Object.onInvokeTask (http://localhost:3000/index.js:59726:37)
at ZoneDelegate.invokeTask (http://localhost:3000/index.js:49474:42)
at Zone.runTask (http://localhost:3000/index.js:49375:47)
at drainMicroTaskQueue (http://localhost:3000/index.js:49607:35)
Oczywiście w przypadku deklaracji klasy w sposób:
export class InstitutionFilter {
direction: string;
field: string;
limit: number;
search: string;
}
Wszystko działa jak należy.
Pomoże ktoś?