为什么我收到Type'Number'没有兼容的呼叫签名。错误?

时间:2018-05-25 16:40:28

标签: angular

嗨,我有这个角度分量代码。

  private approvals: Approval[] = [];

  ngOnInit() {
    this.getUsersApprovals(this.userid);
  }

  getUsersApprovals(userid) {
    this.approvalsService.getUsersApprovals(userid).subscribe(
      data  => this.getSuccess(data),
      error => this.getError(error)
    );
  }

 private getSuccess(data) {
    this.approvals = data;
    let approval_count = this.approvals.length;
  }

当我执行this.approvals.length时,我收到此错误:

Cannot invoke an expression whose type lacks a call signature. Type 'Number' has no compatible call signatures.

我在这里做错了什么?

更新

我能够通过这样做来存档我想要的效果......

let approval_count = data.length;

......但我仍然不明白出了什么问题:

    let approval_count = this.approvals.length;

1 个答案:

答案 0 :(得分:0)

我最终做了什么......

let calendar = Calendar.current
let newDate = calendar.date(byAdding: .year, value: 1, to: Date())