Currently, I am utilizing angularfire2 alongside Angular 5 for my project development. Below is the code snippet:
import { Component, OnInit } from '@angular/core';
import { AngularFirestore, AngularFirestoreCollection, AngularFirestoreDocument } from 'angularfire2/firestore';
import { Observable } from 'rxjs/Observable';
export interface Details {
name: string;
phone: number;
pphone: number;
id: number;
}
@Component({
selector: 'app-add-student',
templateUrl: './add-student.component.html',
styleUrls: ['./add-student.component.css']
})
export class AddStudentComponent implements OnInit {
private studentCollection: AngularFirestoreCollection<Details>;
students: Observable<Details[]>;
constructor(db: AngularFirestore) {
this.studentCollection = db.collection<Details>('collectionName');
this.students = this.studentCollection.valueChanges();
}
ngOnInit() {
}
I have a query regarding accessing the last JSON object stored in
students:Observable<Details[]>
. Is there any feasible method to achieve this? Apologies for any format inconsistencies in my post.