same code executes in constructor of component, but not in service
export interface AppUser {
name: string;
email: string;
isAdmin: boolean;}export interface AppUserId extends AppUser { id: string; }
@Injectable()export class UserService {
AppUserCollection: AngularFirestoreCollection<AppUser>;
AppUsers$: Observable<AppUserId[]>;
constructor(public db: AngularFirestore) {
this.AppUserCollection = this.db.collection<AppUser>('users');
}
getAppUsers() {
alert("here");
return this.AppUsers$ = this.AppUserCollection.snapshotChanges()
.map(actions => {
alert('there');
return actions.map(a => {
const data = a.payload.doc.data() as AppUser;
console.log('Data' + data);
const id = a.payload.doc.id;
return { id, data };
});
});
}
addUser(user: firebase.User) {
this.db.collection('users').add({'name': user.displayName, 'email':
user.email, 'isAdmin': false});
}
// }}
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.