Bal*_*nam 14 angular2-services angular
我是从https://angular.io/docs/ts/latest/guide/router.html关注此示例的
我也试图用服务做类似的列表,但是当我写这行时有些原因
servingpatients = Patient[];
Run Code Online (Sandbox Code Playgroud)
在我的组件中,我收到此错误,如果我删除它,该事情有效.不知道这样做会在样本中做些什么.控制台错误:
未捕获的SyntaxError:意外的令牌]
类型编译期间的终端错误
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)
}
}
Run Code Online (Sandbox Code Playgroud)
Siv*_*iva 42
错误说明在线(35,27),但我在dashboard.component.ts中只能看到11行.
看看你的剧本,唯一的问题就在这里.您将"服务患者"的类型定义为"患者"数组
servingpatients = Patient[];
Run Code Online (Sandbox Code Playgroud)
请将equal(=)更改为冒号(:)以定义类型
servingpatients : Patient[];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25419 次 |
| 最近记录: |