I have the following code
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);
}
});
I would expect the $scope.people to have a new value of and empty array object but it's not been updated, here is the fiddle http://jsfiddle.net/9fR23/409/