Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import { Component, OnInit } from "@angular/core";
import { ActivatedRoute, ParamMap } from "@angular/router";
import { Observable } from "rxjs";
import { switchMap } from "rxjs/operators";
import { PostsService } from "./../posts.service";
selector: "app-post-detail",
templateUrl: "./",
styleUrls: ["./"]
export class PostDetailPage implements OnInit {
constructor(private route: ActivatedRoute, private postSrvc: PostsService) {}
post$: Observable<any>;
ngOnInit() {$ = this.route.paramMap.pipe(
switchMap((params: ParamMap) => this.postSrvc.fetchPost(params.get("id")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.