2016-01-31 9 views
10

byłem po tej próbki z https://angular.io/docs/ts/latest/guide/router.htmlts1109: ekspresja oczekiwać błędu kątowego

i staram się zrobić podobną listę z usługi, jak również, ale z jakiegoś powodu, gdy piszę ten wiersz

servingpatients = Patient[]; 

w moim komponencie dostaję ten błąd, jeśli go usunę, to działa. Nie jestem pewien, co to jednak próbuje zrobić w próbce. Błąd konsola: error

Uncaught SyntaxError: Unexpected token ]

terminala podczas typów kompilacji

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) 
    } 

} 

Odpowiedz

27

Błąd mówi on line (35,27), ale widzę tylko 11 linii tutaj w desce rozdzielczej.component.ts.

Patrząc na swój scenariusz, jedyny problem jest tutaj. Definiowania typ dla „servingpatients” jako tablicę „pacjent”

servingpatients = Patient[]; 

zmień równa (=) do dwukropka (:), aby określić typ

servingpatients : Patient[]; 
+0

Tak, że był problem, DIN nie zauważaj tego. Dzięki. –

Powiązane problemy