Due to the fact that it is used by multiple controllers, I have assigned data to $rootScope.currentCache
. On initial load, that data looks (roughly) like this:
{
System: "Foo Bar",
StartDateTime: "2014-11-27T12:35:00"
}
(ignore formatting errors, they are irrelevant to the question).
In my (abridged) controller I run the following:
app.controller("CurrentController", function ($rootScope, $scope) {
console.log($rootScope.currentCache);
var currentData = $rootScope.currentCache;
//processDate() converts StartDateTime into a friendly format
currentData = processDate(currentData);
console.log($rootScope.currentCache);
});
The first console.log() outputs the date as:
2014-11-27T12:35:00
However, the second console.log() outputs the date as:
Nov 27th 2014 at 12:35pm
This confuses me, as the date processing occurs on the separate currentData
variable.
The other controllers need the date in the original format. So, my question is why is this happening, and how can I stop it?