ts1109:表达式预期 angular 错误
ts1109 : expression expected angular error
我正在关注 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
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"
的数组
servingpatients = Patient[];
请将等号(=)改为冒号(:)来定义类型
servingpatients : Patient[];
我正在关注 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
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"
的数组servingpatients = Patient[];
请将等号(=)改为冒号(:)来定义类型
servingpatients : Patient[];