Check out the code snippet below:
var myapp = angular.module('myapp', []);
myapp.controller('FirstCtrl', function ($scope) {
$scope.people = [
{ id: 1, first: 'John', last: 'Rambo' },
{ id: 2, first: 'Rocky', last: 'Balboa' },
{ id: 3, first: 'John', last: 'Kimble' },
{ id: 4, first: 'Ben', last: 'Richards' }
];
$scope.updateByReference = function() {
var tst = $scope.people;
tst = [];
console.log($scope.people);
}
});
The expectation was for the $scope.people to be an empty array object after running the updateByReference function, but it doesn't seem to be updating. You can test it out on this fiddle: http://jsfiddle.net/9fR23/409/