Created
June 27, 2017 00:07
-
-
Save albaqawi/a5e0f16c97b5f6d90d98359f8b88262d to your computer and use it in GitHub Desktop.
my proplisting code updates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { AngularFireModule } from 'angularfire2'; | |
import { AngularFireDatabaseModule } from 'angularfire2/database'; | |
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database'; | |
import 'rxjs/add/operator/do'; | |
@Injectable() | |
export class FirebaseService { | |
listings: FirebaseListObservable<any[]>; | |
// now this is called as a stand alone constructor | |
constructor(private af: AngularFireDatabase) {} | |
// the get method is called outside the custrustor now in the latest Angular2 version and we use the created instance | |
// of the af object | |
getListings(){ | |
this.listings = this.af.list('/listings') as FirebaseListObservable<listing[]>; | |
return this.listings; | |
} | |
} | |
interface listing { | |
$key?:string; | |
title?:string; | |
title_ar?:string; | |
type?:string; | |
city?:string; | |
city_ar?:string; | |
image?:string; | |
owner?:string; | |
owner_ar?:string; | |
bedrooms?:string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment