I am fairly new in Angular and have a problem connected with assigning a json response from server to new instantiated object.
I have a class MyClass
export class MyClass {
Id: number
}
obj: MyClass;
myService.fetch().subscribe(a=>obj=a);
The problem is, that response from server has five properties and when I assign this response to my object it got them all although this object has only one property "Id".
I am printing both this objects to console by
myService.fetch().subscribe(a=>{
obj=a
console.log(a);
console.log(obj);
}});
And I receive two the same objects. Why this happens? Shouldn't I be notified that assignment cannot be done, because there are missing properties on class MyClass?