angular - how to do an Angular2 Master Detail with firebase -
im getting error : caused by: this.todoservice.getkidsdetails(...).subscribe not function typeerror: this.todoservice.getkidsdetails(...).subscribe not function
here's routing here detailinfocomponent master detail component
import { modulewithproviders } '@angular/core'; import { routes, routermodule } '@angular/router'; import { workerscomponent } './components/workers/workers.component' import { admincomponent } './components/admin/admin.component' import { kidsprofcomponent } './components/kidsprof/kidsprof.component' import { homecomponent } './components/home/home.component'; import { appcomponent } './app.component' import { contentmanagercomponent } './components/content-manager/content-manager.component' import { detailinfocomponent } './components/detailinfo/detailinfo.component' const approuts: routes = [ { path: '', component: homecomponent }, { path: 'kidsprof', component: kidsprofcomponent }, { path: 'detail/:id', component: detailinfocomponent } ] export const routing: modulewithproviders = routermodule.forroot(approuts)
here's kids component id routings
ngoninit() { let id = this._route.snapshot.params['id']; this.kidservice.getkidsdetails(id) .subscribe(kid => this.kid = kid); console.log(this.kid); }
service gets firebase data specific kid
public getkidsdetails(id) { return firebase.database().ref('kids/' + id).once('value'); }
try on extracting route params , using them in kidservice.
ngoninit(){ this._route.params .map(params => params['id']) .subscribe((id) => { this.kidservice.getkidsdetails(id) .subscribe(kid => { this.kid = kid); console.log(this.kid); } }) }); }
and
public getkidsdetails(id) { return firebase.database().ref('kids/' + id).once('value') .map(response => response.json()); }
Comments
Post a Comment