I want to get the current uid from the user so I can get more information of the database.
import { Injectable } from '@angular/core';
import { AngularFire } from "angularfire2";
@Injectable()
export class UserService {
name:string;
constructor(public af: AngularFire) {
this.af.auth.subscribe(auth => {
this.af.object('/users/' + auth.uid);
});
}
}
The auth call works fine but the object call doesn't. But my IDE shows that there is an object function I can use
@cre8 Could you say why you closed this issue? I have the same problem I do have the auth call etc. available. But list isn't, does that mean you should be authorised?
Try af.database.list('/my/path') and af.database.object('/my/path')
Thanks, that works. so the docs are slightly off then I guess?
Angularfire includes auth, database, list and object, but you need a variable with type FirebaseDatabase to get the list or object function.
So I think the angularfire2.d.ts file is broken.
export declare class AngularFire {
private fbUrl;
auth: AngularFireAuth;
database: FirebaseDatabase;
list: (url: string, opts?: FirebaseListFactoryOpts) => FirebaseListObservable<any[]>;
object: (url: string, opts?: FirebaseObjectFactoryOpts) => FirebaseObjectObservable<any>;
constructor(fbUrl: string, auth: AngularFireAuth, database: FirebaseDatabase);
}
Most helpful comment
Try
af.database.list('/my/path')andaf.database.object('/my/path')