I\'m starting to implement a simple pagination using Spring Rest and Angular 5 inside my angular service when I call my web service using httpClient a get a cor
Because the getPageClient
function is asynchronous, pageClient
is undefined when the page first loads. That means when doing pageClient.content
, you will get an error.
Thankfully, Angular provides a useful bit of syntax you can use in the template to avoid this. You should use *ngIf="pageClient?.content" >
instead.
The ?
tells Angular to only read content
if pageClient
is not null / undefined.
More info here