import { Component, Input } from "@angular/core"; import { ISdk, SdkService } from "../services/sdk.service"; @Component({ selector: 'sdk-select-dropdown', template: `
` }) export class SdkSelectDropdownComponent { // FIXME investigate to understand why not working with sdks as input // //@Input() sdks: ISdk[]; sdks: ISdk[]; curSdk: ISdk; constructor(private sdkSvr: SdkService) { } ngOnInit() { this.curSdk = this.sdkSvr.getCurrent(); this.sdkSvr.Sdks$.subscribe((s) => { if (s) { this.sdks = s; if (this.curSdk === null || s.indexOf(this.curSdk) === -1) { this.sdkSvr.setCurrent(this.curSdk = s.length ? s[0] : null); } } }); } select(s) { this.sdkSvr.setCurrent(this.curSdk = s); } }