我从https://angular.io/docs/ts/latest/guide/router.html关注这个示例
我也在尝试用服务做一个类似的列表,但是当我写这行时是有原因的
servingpatients = Patient[];
在我的组件中,我收到了这个错误,如果我删除它,事情就会起作用。不过,不确定这是在示例中尝试做什么。控制台错误:
Uncaught SyntaxError: Unexpected token ]
类型编译期间的终端错误
app/dashboard/dashboard.component.ts(35,27):error TS1109: Expression expected
仪表板.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)
}
}