As a newcomer to Angular, I am facing an issue related to assigning a JSON response from the server to a newly instantiated object.
Within my code, I have defined a class called MyClass:
export class MyClass {
Id: number;
}
let obj: MyClass;
myService.fetch().subscribe(a => obj = a);
The problem arises when the server response contains five properties, but my object only has one property "Id". Surprisingly, all five properties are assigned to the object without any warnings or errors.
To troubleshoot, I print both objects to the console using the following code:
myService.fetch().subscribe(a => {
obj = a;
console.log(a);
console.log(obj);
});
Strangely, despite the mismatch in properties, both objects appear identical in the console. This poses the question - shouldn't there be some form of notification indicating that the assignment cannot be completed due to missing properties in the MyClass class?