Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.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 TypeError:this.mealService.getCardAssignment不是函数_Angular_Kendo Grid - Fatal编程技术网

Angular TypeError:this.mealService.getCardAssignment不是函数

Angular TypeError:this.mealService.getCardAssignment不是函数,angular,kendo-grid,Angular,Kendo Grid,我在一页中使用两个剑道网格。出于某种神圣的原因,第二个网格不工作。 我得到了这些错误 我的第一个网格看起来像这样,工作正常 <kendo-grid [data]="allData" kendoGridSelectBy="id" [selectedKeys]="mySelection" [pageSize]="pageSize"

我在一页中使用两个剑道网格。出于某种神圣的原因,第二个网格不工作。 我得到了这些错误

我的第一个网格看起来像这样,工作正常

<kendo-grid [data]="allData"
              kendoGridSelectBy="id"
              [selectedKeys]="mySelection"
              [pageSize]="pageSize" [skip]="skip" [sort]="gridState.sort"
              [pageable]="true"
              [sortable]="true"
              [reorderable]="true"
              [resizable]="true"
              [scrollable]="true"
              [columnMenu]="{ filter: true }"
              (edit)="onEdit($event)"
              (remove)="onRemove($event)"
              (add)="onAdd($event)">
mealService:

getCardAssignment(params: any) {
    return this.api.post('v1/employees/GetCardAssignment', params);
  }

您应该在
网关分配卡组件的构造函数中声明
mealService
,如下所示:

constructor(private MealService:mealService){}

请包括MealService的代码,请检查问题。我已经编辑过了,订阅是如何触发的?它被绑定为回调吗?是的。与回调一样,您需要绑定回调函数或箭头函数来使用
this
关键字。请看这里:您是对的,但这不是有效的typescript代码。应该是
private mealService:mealService)
@code gorilla感谢您的反馈,更正了它。
getCardAssignment(params: any) {
    return this.api.post('v1/employees/GetCardAssignment', params);
  }
constructor(private MealService:mealService){}