Skip to content

Instantly share code, notes, and snippets.

@zevisert
Last active December 12, 2016 22:16
Show Gist options
  • Save zevisert/8f1b54f16c990a18773e819ae69466fd to your computer and use it in GitHub Desktop.
Save zevisert/8f1b54f16c990a18773e819ae69466fd to your computer and use it in GitHub Desktop.
Post Component
@Component({...})
export class PostComponent implements OnInit {
post: Post;
constructor(
@Inject(BlogService) private blogService: BlogService,
@Inject(ActivatedRoute) private activatedRoute: ActivatedRoute
) { }
ngOnInit(): void {
this.activatedRoute.params.forEach((params: Params) => {
const id: number = +params["id"];
this.blogService
.getPost(id)
.then(data => this.post = new Post(data));
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment