0

ページが読み込まれているときにエラーが発生します

people.ts?9320:22 SyntaxError: Unexpected token 
<(…)PeopleComponent.apiService.people.subscribe.error @ people.ts?
9320:22SafeSubscriber.__tryOrUnsub @ VM38600:166SafeSubscriber.error @ 
VM38600:127Subscriber._error @ VM38600:77Subscriber.error @ 
VM38600:57MapSubscriber._next @ VM38955:51Subscriber.next @ 
VM38600:51onLoad @ VM38808:57ZoneDelegate.invokeTask @ 
VM38526:423NgZoneImpl.inner.inner.fork.onInvokeTask @ 
VM38628:36ZoneDelegate.invokeTask @ VM38526:422Zone.runTask @ 
VM38526:320ZoneTask.invoke @ VM38526:490

これが私のコードです:

export class PeopleComponent {
    people: any;
    constructor(apiService: Api) {
        apiService.people
            .subscribe({
                next: x => (this.people = x),
                error: e => console.error(e), //error line 22 is here!
                complete: () => console.log('Completed!')
            });
    }
}

私のAPIサービス:

import {Injectable} from 'angular2/core';
import { Http } from 'angular2/http';

@Injectable()
export class Api {
  people: any;

  constructor(http: Http) {
    this.people = http.get(require('./people.json'))
      .map(response => response.json());
  }
}

何かご意見は?

4

1 に答える 1