popover-sinonimos.component.ts
1.01 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
import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
import { PopoverDirective } from 'ngx-bootstrap';
import { Producto } from 'src/app/wrappers/producto';
@Component({
selector: 'app-popover-sinonimos',
templateUrl: './popover-sinonimos.component.html',
styleUrls: ['./popover-sinonimos.component.scss']
})
export class PopoverSinonimosComponent implements OnInit {
//Directiva del popover, para poder cerrarlo desde este componente
@Input() popover: PopoverDirective;
@Input() popoverContent: Producto[];
@Output() sinonimoSeleccionado = new EventEmitter<Producto>();
sinonimo: Producto;
constructor() { }
ngOnInit() {
//Seteo en la variable a emitir el sinonimo que sea padre
this.popoverContent.forEach(sinonimo => {
this.sinonimo = sinonimo.esPadre ? sinonimo : undefined;
})
}
hidePopover() {
this.sinonimoSeleccionado.emit(this.sinonimo);
this.popover.hide();
}
setSinonimo(sinonimo: Producto) {
this.sinonimo = sinonimo;
}
}