import { Component, ElementRef, Input, OnInit } from '@angular/core';
import { fromEvent, mapTo, Observable } from 'rxjs';

@Component({
  selector: 'app-option',
  template: `
    <div class="option">
      <ng-content></ng-content>
    </div>
  `
})
export class AppOptionComponent implements OnInit {  
  @Input() value: string = "";  
  click$: Observable<string> = new Observable<string>();  
  
  constructor(private host: ElementRef) {}  
  
  ngOnInit() {  
    this.click$ = fromEvent(this.element, 'click').pipe(mapTo(this.value));  
  }  
  
  get element() {  return this.host.nativeElement; }  
}
