I have simple class in TS:
export class TestObj
{
public name:string;
public id:number;
public example:string;
}
And simple service:
@Injectable()
export class SimpleService
{
private testObj:TestObj = new TestObj();
public constructor(@Inject(Http) private http:Http){}
public getTestObj():void
{
this.http.get("/rest/test2").map(res => res.json())
.do(data => console.log(<TestObj> data))
.catch(resp => Observable.throw(resp.json().error))
.subscribe(tobj => {
this.tobj = tobj;
console.log(this.tobj);
}, error => {log.error(error)})
}
If I will print in console log SimpleService.testObj before getTestObj(), I saw
<TestObj>
, but if I will run getTest, log will be
<Object>
<Object>
Is it angular bug? Or Typescript bug?