【发布时间】:2016-01-31 08:05:01
【问题描述】:
我从https://angular.io/docs/ts/latest/guide/router.html关注这个样本
我也在尝试用服务做一个类似的列表,但是当我写这行时出于某种原因
servingpatients = Patient[];
在我的组件中,我收到了这个错误,如果我删除它,事情就会起作用。 不过,不确定这是在示例中尝试做什么。 控制台错误:
Uncaught SyntaxError: Unexpected token ]
类型编译期间出现终端错误
app/dashboard/dashboard.component.ts(35,27):error 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)
}
}
【问题讨论】: