angular - Using resolve in angularfire2 -


i trying use route resolve in angularfire2 project. have blog page list of blogs.

blogs-resolve.service.ts

import { injectable } '@angular/core'; import { resolve, activatedroutesnapshot } '@angular/router'; import { blog } '../../shared/models/blog'; import { firebaseservice } './firebase.service'; import { observable } 'rxjs'; import 'rxjs/add/operator/first';  @injectable() export class blogsresolve implements resolve<blog> {    constructor(private firebaseservice: firebaseservice) {}    resolve(route: activatedroutesnapshot): observable<any>|promise<any>|any {     return this.firebaseservice.getblogs().map(blogs => {       console.log(blogs)        blogs;     }).first();   } } 

the getblogs() firebaseservice returns list of blogs. , above console.log gives array of objects i.e. no of blogs have.

but in component when try console log data, shows undefined.

blogs.component.ts

import { component, oninit } '@angular/core'; import { activatedroute } '@angular/router'; import {firebaseservice} '../../shared/services/firebase.service'; import { angularfireauth } 'angularfire2/auth'; import * firebase 'firebase/app'; import { blog } '../../shared/models/blog';  export class blogscomponent implements oninit {   blogs: blog[];    constructor(     private firebaseservice: firebaseservice,     private route: activatedroute   ) { }    ngoninit() {     this.route.data.foreach((data: { blogs: blog[] }  => {       console.log(data.blogs)   })  } } 

any appreciated. thank you


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -