export class MyClass {
data: MyData;
constructor(private dataService: DataService) {
this.data = this.dataService.getData(); // issue
}
}
export class DataService{
data: MyData;
constructor(private http: Http) { }
getData(): Observable<MyData>{
return Observable.from([this.fakeData()]
.map(res=>res as MyData));
}
private fakeData() : MyData {
...
}
}
An error has occurred on line
this.data = this.dataService.getData()
The type Observable cannot be assigned to MyData