Advertisement
torokt21

postcomponent1

May 29th, 2023
1,156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import {Component, OnInit} from '@angular/core';
  2. import {Post} from "../../_models/post";
  3. import {PostService} from "../../post.service";
  4.  
  5. @Component({
  6.   selector: 'app-list-posts',
  7.   templateUrl: './list-posts.component.html',
  8.   styleUrls: ['./list-posts.component.scss']
  9. })
  10. export class ListPostsComponent implements  OnInit{
  11.  
  12.   subjectId:string=''
  13.   posts: Post[]
  14.   constructor(private postService: PostService) {
  15.   }
  16.  
  17.   ngOnInit(): void {
  18. // Post id megszerzése a route-ból, ezt már egyszer megcsináltuk a projekt munkában
  19.     this.subjectId = ....
  20.     this.postService.getPosts(this.subjectId).subscribe(posts => this.posts = posts)
  21.   }
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement