4

This is my .ts file

import { Component, OnInit } from '@angular/core';
import { AngularFireDatabase, FirebaseListObservable, FirebaseObjectObservable } from 'angularfire2/database';

@Component({
  selector: 'app-candidate-reg-success',
  templateUrl: './candidate-reg-success.component.html',
  styleUrls: ['./candidate-reg-success.component.css']
})
export class CandidateRegSuccessComponent implements OnInit {

  constructor() { 
    debugger;
    const rootRef=firebase.database.ref();
    const mail=rootRef.child('candidates_list').orderByChild('email').equalTo('[email protected]');
    console.log(mail);

  }

  ngOnInit() {
  }

}

I am trying to query the user from candidates_list table which has the email address [email protected].

But I am unable to console it. It shows a error like

Property 'ref' does not exist on type 'typeof database'.

Any solution to query angular firebase database?

3
  • 1
    firebase.database.ref(); => firebase.database().ref(); Commented Jun 21, 2017 at 14:10
  • sir when i changed like above they are showing firebase is not defined eroor?Please help me Commented Jun 21, 2017 at 14:22
  • That error message would have existed before the change too. It looks like you should use AngularFire's built-in querying capabilities: github.com/angular/angularfire2/blob/master/docs/… Commented Jun 21, 2017 at 14:42

1 Answer 1

3

you need to inject the AngularFirebaseData in constructor and change the code and try again

import { Component, OnInit } from '@angular/core';
import { AngularFireDatabase, FirebaseListObservable,   
   FirebaseObjectObservable } from 'angularfire2/database';

@Component({
  selector: 'app-candidate-reg-success',
 templateUrl: './candidate-reg-success.component.html',
 styleUrls: ['./candidate-reg-success.component.css']
})
  export class CandidateRegSuccessComponent implements OnInit {

  constructor(public db: AngularFireDatabase) { 
    debugger;
    db.list('/candidates_list', ref => ref.orderByChild('email').equalTo('[email protected]'));
}   
 ngOnInit() {
    }}
Sign up to request clarification or add additional context in comments.

8 Comments

Hi @Chellappan வ this works perfectly for me can you give one example how can I query having multiple parameters like email name etc etc?
Yes I tried with fire store but was upset by getting this error I already have a question for this error on stack overflow but this question is not answered yet the error is This likely means that the library (@angular/fire/firestore) which declares AngularFirestore has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.
It seems it's supported by angular 9+ github.com/angular/angularfire/tree/6.0.2
Yes thats the main problem do you know about the querybase? I was trying a hand over it I just ran the npm command and installed it but I dont know how to import and use this it would be great if you can provide some guidence here stackoverflow.com/questions/63113829/…
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.