Created
October 9, 2018 08:27
-
-
Save considine/96425ad5c17ac179a9ffd680afd76ef0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | |
@Component({ | |
selector: "app-post-detail", | |
templateUrl: "./post-detail.page.html", | |
styleUrls: ["./post-detail.page.scss"] | |
}) | |
export class PostDetailPage implements OnInit { | |
constructor(private route: ActivatedRoute, private postSrvc: PostsService) {} | |
post$: Observable<any>; | |
ngOnInit() { | |
this.post$ = 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