import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ApiService } from 'src/app/services/api.service';
@Component({
selector: 'app-album-single',
templateUrl: './album-single.component.html',
styleUrls: ['./album-single.component.scss'],
})
export class AlbumSingleComponent implements OnInit {
id: number;
title: string;
photos: any = '';
constructor(private readonly route: ActivatedRoute, private readonly apiService: ApiService) {}
ngOnInit(): void {
//kinyeri az 'id' nevű paraméter értékét, és hozzárendeli azt a komponens id változójához.
this.route.params.subscribe((params) => {
this.id = params['id'];
});
// Az adott album lekérése az id alapján
this.apiService.getAlbum$(this.id).subscribe((album) => {
this.title = album.title;
});
// Az album képek lekérése az id alapján
this.apiService.getAlbumById$(this.id).subscribe((albumData) => {
this.photos = albumData;
console.log(this.photos);
});
}
}