Ash
Ash

Reputation: 574

Issue setting the value within controller & strange result from console.log

Trying to set the value of some object and display it in the view however As you can see after setting the vm.order.info.when value into 'Any Value' and console.log the vm.order.info I get the value in the first half of the object right but when i extend the object I also see the same value as undefined.

vm.order.info.when = 'any value';
console.log(vm.order.info);

Is this normal and if so whats causing it ?

Here you can see my console displaying the issue I was trying to explain

Upvotes: 1

Views: 47

Answers (1)

Prabhjot Singh Rai
Prabhjot Singh Rai

Reputation: 2545

Try hovering over the blue i icon on the right side of the output. You will find the answer.

Explaination: When you are printing out the value by console.log, you get the value at the time when your code reaches the line console.log(vm.order.info). But when you open the object inside the browser, you get the object which is formed when all your code runs/code that executed till you clicked to expand the object in the console. Thus, after your console.log statement, the code must have modified vm.order.info object, somewhere.

Upvotes: 1

Related Questions