получаю ошибку при использовании угловых 4 и наблюдаемых.
ОШИБКА в src / app / ca-calendar / calendar.component.ts (84,5): ошибка TS2322: тип «Наблюдаемый» не может быть назначеннабрать «Наблюдаемый».Тип «Год» нельзя назначить типу «Год []».Свойство "include" отсутствует в типе "Year".
Что я делаю не так?
Сервис:
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import { Year, Month } from '../../models';
@Injectable()
export class CalendarService {
endPoint: string;
private _calendarUrl = '/api/mycalendar';
constructor(private http: HttpClient) {
}
getYear(id: string): Observable<Year> {
return this.http.get(this._calendarUrl + '?id=' + id)._catch(this.handleError);
}
getYears(): Observable<Year> {
return this.http.get(this._calendarUrl)
.map((res: Response) => res.json())
._catch(this.handleError);
Компонент:
import { Component, OnInit } from '@angular/core';
import { MonthCalendarComponent } from './month-calendar/month-calendar.component';
import { Month } from '../models/month';
import { MonthsService } from '../services/calendar/months/months.service';
import { CalendarService } from '../services/calendar/calendar.service';
import { Year } from '../models';
import { Observable } from 'rxjs/Observable';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'ca-calendar',
templateUrl: './calendar.component.html',
styleUrls: ['./calendar.component.css']
})
export class CalendarComponent implements OnInit {
public myYears$: Observable<Year[]>;
constructor(private calendarService: CalendarService, private monthsService: MonthsService) {}
ngOnInit() {
this.myYears$ = this.calendarService.getYears();
}
... и модель
import { Month } from './month';
import { Week } from './week';
export class Year {
id: String;
number: Number;
months: Month[];
weeks: Week[];
constructor() {
}
}