Angular ts1109:表达式预期的角度误差

Angular ts1109:表达式预期的角度误差,angular,angular2-services,Angular,Angular2 Services,我一直在跟踪这个样本 我也试着用一个服务做一个类似的列表,但写这行的时候有一些原因 servingpatients = Patient[]; 在我的组件中,我得到了这个错误,如果我删除它,它就会工作。 不过,我不确定这在示例中要做什么。 控制台错误: 未捕获的语法错误:意外标记] 类型编译期间的终端错误 app/dashboard/dashboard.component.ts(35,27):错误TS1109:表达式 期望 dashboard.component.ts import {Compo

我一直在跟踪这个样本

我也试着用一个服务做一个类似的列表,但写这行的时候有一些原因

servingpatients = Patient[];
在我的组件中,我得到了这个错误,如果我删除它,它就会工作。 不过,我不确定这在示例中要做什么。 控制台错误:

未捕获的语法错误:意外标记]

类型编译期间的终端错误

app/dashboard/dashboard.component.ts(35,27):错误TS1109:表达式 期望

dashboard.component.ts

import {Component, OnInit} from 'angular2/core';
import {Patient, DashboardService} from './dashboard.service';
import {Router} from 'angular2/router';
export class DashboardComponent implements OnInit{

servingpatients = Patient[];

  constructor(private _service : DashboardService,
    private _router: Router){}


  ngOnInit(){
  this._service.getServingPatients().then(servingpatients => this.servingpatients = servingpatients)
  }

}
错误显示在第(35,27)行,但我在dashboard.component.ts中只能看到11行

看看你的剧本,唯一的问题就在这里。您正在将“servingpatients”的类型定义为“Patient”数组

请将equal(=)更改为冒号(:)以定义类型

servingpatients : Patient[];
servingpatients : Patient[];