angular - Assign Observable to do dynamic query in angularfire2 list -
is there way pass in entire query observable? method end calling query twice once startat
, once endat
. want search wildcard.
import { component, oninit } '@angular/core'; import { angularfire, firebaselistobservable } 'angularfire2'; import { subject } 'rxjs'; @component({ selector: 'app-search', templateurl: './search.component.html', styleurls: ['./search.component.css'] }) export class searchcomponent implements oninit { private sources: firebaselistobservable<any>; private uid: string; private searchsubject: subject<searchsubject>; private search: search; constructor(private af: angularfire) { this.search = new search(""); this.searchsubject = new subject<searchsubject>(); af.auth.subscribe(d => { this.uid = d.uid; this.sources = af.database.list('/sources', { query: { orderbychild: 'name', startat: this.searchsubject.map(d=>{ return d.startat; }), endat: this.searchsubject.map(d=>{ return d.endat; }) } }); this.sources.subscribe(d=>{ console.log(d); }); }); } ngoninit() { } onsearch(form: any): void { this.searchsubject.next(new searchsubject('name',this.search.value,this.search.value+"\uf8ff")); } } export class search { constructor( public value: string ) { } } export class searchsubject { constructor( public orderbychild:string, public startat: string, public endat: string ) { } }
Comments
Post a Comment