ArrayUtility.js

angular.module('homepage').
factory('ArrayUtility', function() {
    return {
        reassignArray: reassignArray
    };

    /**
     * Reassign new array to original array preserving the original array reference
     */
    function reassignArray(originalArray, newArray) {
    	// Empty original array keeping the original reference
    	originalArray.length = 0;
    	// Add all items of new array to original array
    	// originalArray.concat(newArray);  This doesnt work with object arrays
        for(var index in newArray) {
            var item = newArray[index];
            originalArray.push(item);
        }

    	return originalArray;
    }
});