属性 在类型 'Component' 上不存在

Property does not exist on type 'Component'

我是 angular 的新手,我想删除一台机器,但我在控制台中收到错误消息:

HttpErrorResponse {headers: HttpHeaders, status: 400, statusText: "Bad Request", url: "http://localhost:3001/machines/delete", ok: false, …}

不知道怎么解决。这是我的组件代码:

constructor (MachinesService: MachinesService, private toastr: 
ToastrService) {
MachinesService.getMachines().subscribe(
    res => {
          console.log(res);
          this.machines = res;
    },

    err => {
          console.log(err);
    }
  );

    }

       delete(id) {
    this.MachinesService.deleteMachine(id).subscribe();
  }

和我的 machinesService.ts :

 deleteMachine(id): Observable<any> {
 return this.http.post(environment.apiUrl + '/machines/delete', id);

我已经使用过相同的代码并且运行良好,但我不知道现在的问题是什么。 注意:它在后端工作。

您在构造函数参数前忘记了 private。这也是它成为 属性 的原因。

请不要以与类型相同的方式命名变量。对变量使用小写第一个字符。