Please consider the small angularJs code snippet below.
$scope.myArray = [];
function sampleMethod(){
$scope.myArray.push({
name: $scope.name,
age: $scope.age
});
console.log($scope.myArray.name);
};
Here, I was trying to get the scope values name and age and loading it to a scope array inside a controller. But the above program prints nothing. Cant we access and feed scope values to an array from controller? If not possible, how can I do it correctly?