Skip to content

Instantly share code, notes, and snippets.

@shafiqshams
Created August 8, 2017 19:22
Show Gist options
  • Save shafiqshams/0c71d8df0b55f80fbeb34a80fce81ad4 to your computer and use it in GitHub Desktop.
Save shafiqshams/0c71d8df0b55f80fbeb34a80fce81ad4 to your computer and use it in GitHub Desktop.
To avoid shows console error if the user is not authenticated to get listings from Firebase. [Angular 2 & Firebase App [Part 4] - Firebase Authentication]
import { Component, OnInit } from '@angular/core';
import { FirebaseService } from '../../services/firebase.service';
@Component({
selector: 'app-listings',
templateUrl: './listings.component.html',
styleUrls: ['./listings.component.css']
})
export class ListingsComponent implements OnInit {
listings:any;
constructor(private firebaseService: FirebaseService) { }
ngOnInit() {
this.firebaseService.getListings().subscribe(listings => {
console.log(listings);
this.listings = listings;
}, err => {
console.log(err);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment