import { Component, OnInit, OnDestroy, Input } from '@angular/core'; import { ApiContainerService } from './api-container.service'; @Component({ selector: 'cm-api-container', templateUrl: './api-container.component.html', styleUrls: ['./api-container.component.css'] }) export class ApiContainerComponent implements OnInit, OnDestroy { panel = { active: true, disabled: false, name: 'API 列表' } apis: any[] = []; @Input() set apiPath(apiPath: string) { this.apiService.getApi(apiPath).then(data => { this.apis = data; }); } @Input() set isCollapsed(isCollapsed: boolean) { if (isCollapsed == true || isCollapsed.toString() == "true") { this.panel.active = false; } else { this.panel.active = true; } } constructor(private apiService: ApiContainerService) { } ngOnInit() { } ngOnDestroy() { } }