how to get firebase document id angular 1

how to get firebase document id angular

ngOnInit() {
  this.myEventList = this.firestore
    .collection('eventList')
    .valueChanges({ idField: 'eventId' });
}

Here is what the above code is Doing:
1. We are importing the AngularFirestore service from the AngularFire2 library.
2. We are injecting the AngularFirestore service into the constructor of the component.
3. We are creating a property called myEventList and assigning it to the valueChanges() method of the AngularFirestore service.
4. We are passing an object to the valueChanges() method. This object has a property called idField and we are assigning it to the eventId property of the eventList collection.

Now, let’s see how we can display the data in the template.

Similar Posts