Angularfire: TypeError: this.af.list is not a function

Created on 14 Jul 2016  路  4Comments  路  Source: angular/angularfire

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

Most helpful comment

Try af.database.list('/my/path') and af.database.object('/my/path')

All 4 comments

@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);
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

martinyoussef picture martinyoussef  路  3Comments

adriandurran picture adriandurran  路  3Comments

StephenFluin picture StephenFluin  路  3Comments

KLiFF2606 picture KLiFF2606  路  3Comments

DennisSmolek picture DennisSmolek  路  3Comments