informacion.component.ts
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { ImagesService } from 'src/app/services/images.service';
import { Image } from 'src/app/models/typedefs';
import { flatMap, filter } from 'rxjs/operators';
@Component({
selector: 'app-informacion',
templateUrl: './informacion.component.html',
styleUrls: ['./informacion.component.css']
})
export class InformacionComponent implements OnInit {
public image : Image;
public funciones : boolean = false;
public entradas : boolean = false;
public tiempo : boolean = false;
public teatro : boolean = false;
constructor(
private route : ActivatedRoute,
private router : Router,
private images : ImagesService
) {}
ngOnInit(): void {
this.route.paramMap.pipe(
/** foreach entry (which is only one) of paramMap **/
flatMap(
/**
* Produce a new observable of images where you filter by the name parameter
* O(images), reduce to O(1) with a Map structure in ImagesService
*/
param => this.images.getImages().pipe(
filter( (i : Image) => i.name === decodeURIComponent(param.get('name')) )
)
)
)
/** subscribe to it and receive the image to know its values **/
.subscribe( (i : Image) => this.image = i );
}
showInfo(show : string) {
this.funciones = this.teatro = this.tiempo = this.entradas = false;
switch (show) {
case "Funciones":
this.funciones = true;
break;
case "Entradas":
this.entradas = true;
break;
case "Tiempo":
this.tiempo = true;
break;
case "Teatro":
this.teatro = true;
break;
}
}
}