I have the following simple controller in my Angular app
vehicleSearchApp.controller('VehicleSearchCtrl', function ($scope, $location){
$scope.location = $location;
$scope.$watch('location.search()', function() {
$scope.target = ($location.search()).target;
}, true);
$scope.changeTarget = function(name) {
$location.search('target', name);
}
console.log($scope.target);
console.log($scope);
}
The first console log statement towards the bottom of the controller returns undefined, but the second console log statement returns an object that looks like the following:

I see the 'target' property plus a host of other methods / properties in this object. Why do I get an 'undefined' message in console if I try to print using "console.log($scope.target)"?