I have Angular 5 + Firebase app, where I get items from a Firebase list and set them into a view with *ngFor.
<a routerLink="post/{{post.url}}" *ngFor="let post of (posts | async)">
<h2>{{ post?.title }}</h2>
<span>{{ post?.date }}</span>
</a>
Every item I have a "Date" field in the format "dd.mm.yyyy". How can I set them into component view sorted by date (from newest to older)?
How can I get posts from Firebase:
getPosts(): Observable<any[]> {
return this.db.list('posts').snapshotChanges().map(changes => {
return changes.map(c => ({
key: c.payload.key,
...c.payload.val() }));
});
}