I have an AFS observable which I can show in my frontend like this:
constructor(
public fb: FirebaseProvider,
) {
this.group = this.navParams.get('group');
this.contactsList = this.fb.getContactsByGroup(this.group.id);
}
My fb service:
getContactsByGroup(groupId: string):Observable<Contact[]> {
return this.afs.collection<Contact>(`groups/${groupId}/contacts`).valueChanges();
}
Then my template:
<single-contact-list-item
[contactId]="contact.id"
(goToModalEvent)="onGoToModal($event)"
*ngFor="let contact of contactsList | async">
</single-contact-list-item>
Now I have a textarea which when submitted triggers an event. What I want to do is loop through each item in the Observable (contactsList) and get a property, for example:
public sendSMS(): void {
this.contactsList.forEach(contact => {
console.log(contact.number); // nothing!
})
//this.deviceProvider.sendSMS(this.contactsList, this.message);
}
I feel like the issue is that by using the async pipe in the template the Observable is already subscribed. Any help appreciated.