`
//providers/person.ts
import { Injectable } from '@angular/core';
import {AngularFireDatabase} from 'angularfire2/database';
import {Person} from './Person.ts';
@Injectable()
export class PersonProvider {
private personListRef = this.db.list<Person>('persons');
constructor(private db: AngularFireDatabase) {}
/**
* Creates Person
*/
createPerson(person: Person) {
return this.personListRef.push(person);
}
/**
* Reads Persons
*/
getPersons() {
return this.personListRef;
}
/**
* Updates Person
*/
updatePerson(person: Person) {
return this.personListRef.update(person.key, person);
}
/**
* Deletes Person
*/
deletePerson(person: Person) {
return this.personListRef.remove(person.key);
}
}
`
Depending on the version of AngularFire2 you are using (tested with 5.0.0-rc.11), you may need to install rxjs@6.
npm install rxjs@6 rxjs-compat@6 --save