Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 类型搜索没有兼容的调用签名。5+;_Angular_Typescript - Fatal编程技术网

Angular 类型搜索没有兼容的调用签名。5+;

Angular 类型搜索没有兼容的调用签名。5+;,angular,typescript,Angular,Typescript,我从中获得的addItem函数向我发出以下错误消息: 错误TS2349(TS)无法调用其类型缺少调用的表达式 签名。类型“Search”没有兼容的呼叫签名 接口: export interface Search { name: String; type: String; inputValue: String; } 减赤: array : Search[]; searches: Search[]; 打字稿: addItems(startIndex, endIndex,

我从中获得的
addItem
函数向我发出以下错误消息:

错误TS2349(TS)无法调用其类型缺少调用的表达式 签名。类型“Search”没有兼容的呼叫签名

接口:

export interface Search {
    name: String;
    type: String;
    inputValue: String;
}
减赤:

array : Search[];
searches: Search[];
打字稿:

addItems(startIndex, endIndex, _method) {
    let movieIndex = 0
    for (let i = 0; i < this.sum; ++i) {
      movieIndex++;
      if (movieIndex >= this.searches.length) movieIndex = 0;
      this.array[_method](this.searches[movieIndex]);
    }
}
此声明

this.array[_method](this.searches[movieIndex]);
表示您试图获取
\u方法
-this.array
的第项
,并希望调用它(
()
这是函数的调用)传递参数
this.searches[movieIndex]
,但您的数组包含
Search
类型的元素,该元素不可调用

this.array[_method] ( this.searches[movieIndex] );
                    ^ ^------ parameter ------^ ^
                    ^ ------ function call -----^  

当我使用带有json数据的数组时,它可以工作,但当我尝试使用接口时,会收到错误消息。界面是否可能获得相同的结果,或者我是否必须使用数组?当使用json数据时,数组中有什么?我使用
app.component.ts
movies数组中的示例json。在该示例中,它不是访问项目,而是访问
数组的功能,例如
推送
弹出
。可能您没有传递函数键?是的,
this.addItems(startIndex,endIndex,'push')
这个.addItems(startIndex,endIndex,'unshift')
this.array[_method] ( this.searches[movieIndex] );
                    ^ ^------ parameter ------^ ^
                    ^ ------ function call -----^