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-successponent.html',
styleUrls: ['./candidate-reg-successponent.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?
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.ponent.html',
styleUrls: ['./candidate-reg-success.ponent.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?
Share Improve this question edited Jul 5, 2018 at 18:19 marc_s 757k184 gold badges1.4k silver badges1.5k bronze badges asked Jun 21, 2017 at 13:48 pranavyoyopranavyoyo 851 silver badge6 bronze badges 3-
1
firebase.database.ref();
=>firebase.database().ref();
– Frank van Puffelen Commented Jun 21, 2017 at 14:10 - sir when i changed like above they are showing firebase is not defined eroor?Please help me – pranavyoyo 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./angular/angularfire2/blob/master/docs/… – Frank van Puffelen Commented Jun 21, 2017 at 14:42
1 Answer
Reset to default 3you 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.ponent.html',
styleUrls: ['./candidate-reg-success.ponent.css']
})
export class CandidateRegSuccessComponent implements OnInit {
constructor(public db: AngularFireDatabase) {
debugger;
db.list('/candidates_list', ref => ref.orderByChild('email').equalTo('[email protected]'));
}
ngOnInit() {
}}