This is expected behavior.
When you created the controller's showVars
function, you are closing over $scope
, which is the scope of the parent controller. So when you reference $scope
, you are getting that scope that was injected into the controller.
In other words, $scope
doesn't change based on the execution of the function. This is why you want to pass the item into the function as a parameter.
If you want access to the child scope in the function, you can do this using this
:
this.item.ID
Here is a working JS Fiddle