add shows

This commit is contained in:
Phan Huy Tran 2024-11-20 12:39:45 +01:00
parent 6d6a817a47
commit 5f7968a756

View File

@ -3,6 +3,7 @@ import {ShowService} from '../../services/show.service';
import {Show} from '../../model/show';
import {FormsModule} from '@angular/forms';
import {Observable} from 'rxjs';
import {addDoc, collection, Firestore} from '@angular/fire/firestore';
@Component({
selector: 'app-show-form',
@ -14,13 +15,12 @@ import {Observable} from 'rxjs';
styleUrl: './show-form.component.css'
})
export class ShowFormComponent {
showService: ShowService = inject(ShowService);
fireStore: Firestore = inject(Firestore);
private seriesCollection = 'table_show';
show: Show = new Show(0, "");
shows: Observable<Show[]> = this.showService.getShows();
save() {
// this.shows.push(this.show);
this.show = new Show(0, "");
const showsRef = collection(this.fireStore, this.seriesCollection);
addDoc(showsRef, {id: this.show.uid, title: this.show.title,});
}
}