Working away on a Ionic-PouchDB - I'm new to both - and pretty basic at JS.
I have a service that returns data from PouchDB and an ngfor loop that populates the view. It works fine
From the page typescript
ngOnInit() {
this.slates = this.api.getSlates();
}
From the HTML
<ion-content>
<ion-list>
<ion-item button detail lines="inset" *ngFor="let slate of slates" (click)="openDetails(slate)">
{{ slate.createdon | date:'EEE - d - LLL hh:mm a yyyy' }} --- {{ slate._id }}
</ion-item>
</ion-list>
</ion-content>
If I console.log this.slates I get
So far so good
I need to find out how many objects there are in the what look like an array - in this case 10. Also need to be able to get hold of data in each element. e.g. the _id or type from the objects
If I do say
ngOnInit() {
this.slates = this.api.getSlates();
console.log(this.slates);
console.log(Object.keys(this.slates));
}
I just get an empty array.
Any help much appreciated - it'll help my sanity.