please put some of your code, but this should be straight forward to do in the three steps below. Here is a ref just Search or CRUD sample with search and save
- Create a Button inside your angular template. Below you have
drop down select
like so -- SearchAppComponent.html
:
<ul>
<li class="text" *ngFor="let movies of moviess | async">
<a href="#" (click)="selectMovies(movies)">{{movies.name}}</a>
</li>
</ul>
<div>Selected Movies: {{myMovies?.name}}</div>
<button (click)="updateSelectedMovies()">Update Movies</button>
- Your
model
of whatever you want to search
export interface Movies {
name: string;
category: string;
}
- Handle the
select
or click event
, Inside your selectChanges event, or a button click event in you searchappcomponent.ts
file
async selectMovies(movies: Movies) {
const snapshotResult = await this.db.collection('movies', ref =>
ref.where('name', '==', movies.name)
.limit(1))
.snapshotChanges()
.pipe(flatMap(moviess => movies));
snapshotResult.subscribe(doc => {
this.myMovies = <Movies>doc.payload.doc.data();
this.moviesRef = doc.payload.doc.ref;
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…