このようなコンポーネントを作成していて、サーブ/ビルドにエラーが発生しています。 いくつかのコメント投稿者が考えているように、コンソールのエラーと混同しないでください。 予想される動作は、ビルドと実行のコードです。解決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) - 署名) – orangespark
@orangesparkいいえ..私はそれを渡すでしょう。それを比較して重複をマークしてください。エラーは同じです。異なるユースケースです。 –