1import {Component} from '@angular/core';
2import { AngularFireDatabase } from 'angularfire2/database';
3
4@Component({
5 selector: 'app-root',
6 templateUrl: './app.component.html',
7 styleUrls: ['./app.component.css']
8})
9export class AppComponent {
10 courses$;
11 courseObservable;
12 authors$;
13 constructor(db: AngularFireDatabase) {
14 this.courseObservable = db.list('/courses');
15 this.courses$ = this.courseObservable.valueChanges();
16 this.authors$ = db.object('/authors/1').valueChanges();
17
18 }
19 add(course: HTMLInputElement) {
20 this.courseObservable.push(course.value);
21 course.value = '';
22 }
23}
24