이와 같은 구성 요소를 만들고있어 서비스/건물에 오류가 발생했습니다. 일부 의견 작성자가 생각하는 것처럼 콘솔의 오류와 혼동하지 마십시오. 예상되는 동작은 빌드 및 실행 코드입니다. 해결 foreach는 함수 AngularX TS 오류 형식에 통화 서명이없는 표현식을 호출 할 수 없습니다.
TS error TS2349: Cannot invoke an expression whose type lacks a call signature
import { Component, OnInit, Input } from '@angular/core';
import { ChartInput, MultiChartInput, ChartColorScheme } from "@shared/models/chart-input";
@Component({
selector: 'chart-legend',
templateUrl: './chart-legend.component.html',
styleUrls: ['./chart-legend.component.css']
})
export class ChartLegendComponent implements OnInit {
@Input()
public chartInput: ChartInput[] | MultiChartInput[];
@Input()
public legendColors: ChartColorScheme;
public legends: Map<string, string> = new Map<string, string>();
constructor() { }
ngOnInit() {
this.chartInput.forEach(
(item, index) => {
this.legends.set(item.name, this.legendColors.domain[index]);
});
}
}
export class ChartInput {
name: string;
value: number;
}
export class MultiChartInput {
name: string;
series: ChartInput[];
}
export class ChartColorScheme {
domain: string[];
}
ngOnInit()
에서 어떤 도움을 받고있다. 누군가가이 내용과 관련 있다고 생각하면 question입니다. 설명 해주십시오. 나는 그렇게 생각하지 않는다.
ngOnInit()에서 console.log (this.chartInput)를 확인하십시오. – Ajay
가능한 오류 : [오류 : 유형에 통화 서명이없는 표현식을 호출 할 수 없음] (https://stackoverflow.com/questions/39691889/error-cannot-invoke-an-expression-whose-type-lacks-a-call -signature) – orangespark
@orangespark 아니 .. 나는 그것을 전달합니다. 그것을 비교하고 중복을 표시하십시오. 오류는 동일합니다. 그러나 다른 유스 케이스. –