Hi,
I am using JaveBratt’s sample project where I want to assign task to members. All seems working but I am not able to fetch the member data in the ngFor Loop. Following are the codes:
HTML:
<ion-list>
<ion-item>
<ion-label>Assign to</ion-label>
<ion-select [(ngModel)]="teamMemberModel" formControlName="teamMember">
<ion-option *ngFor="let member of memberList" [value]="member">
{{ member.fullName }}
</ion-option>
</ion-select>
</ion-item>
</ion-list>
TS:
ionViewDidEnter(){
this.teamProvider.getUserProfile().subscribe( userProfileObservable => {
this.teamProvider.getTeamMemberList(userProfileObservable.$key)
.subscribe( teamListObservable => {
this.memberList = teamListObservable;
});
});
}
Following are the providers details:
getUserProfile(): FirebaseObjectObservable<any> {
return this.afDb.object(`/userProfile/${this.userId}/`);
}
and
getTeamMemberList(teamId:string): FirebaseListObservable<any> { return this.afDb.list(
/teamProfile/${teamId}/teamMember); }
I am using Firebase cloud function too:
exports.createTeamMember = functions.database.ref(
/teamProfile/{teamId}/teamMembers/{memberId}`)
.onWrite( event => {
if (event.data.previous.exists()) {
console.log("User edited, exiting the function now");
return;
}
console.log("Accessing parent ref");
return event.data.adminRef.parent.parent.child("teamName").once('value', snapshot => {
const teamId = event.params.teamId;
const memberId = event.params.memberId;
const email = event.data.val().email;
const fullName = event.data.val().fullName;
const teamName = snapshot.val();
console.log("Creating user...");
return admin.auth().createUser({
uid: memberId,
email: email,
password: "123456789",
displayName: fullName
})
.then( newUserRecord => {
console.log("Creating user profile...");
return admin.database().ref(`/userProfile/${memberId}`).set({
fullName: fullName,
email: email,
teamAdmin: false,
teamId: teamId,
teamName: teamName
})
});
}).catch((error) => { console.error("Error creating new user:", error); });`