`
//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);
}
}
`
根据您使用的 AngularFire2 版本(使用 5.0.0-rc.11 测试),您可能需要安装 rxjs@6。
npm install rxjs@6 rxjs-compat@6 --save