GlobalDataSrvc.js

angular.module('homepage').
// Store templates, location and widget data
factory('GlobalDataService', function (DateUtility) {
	var selectedDate = new Date();
	var isTodaysDate = {
		isTrue: true
	};
	function getSelectedDate() {
		return selectedDate;
	}

	function setSelectedDate(date) {
		selectedDate.setTime(date.getTime());
		isTodaysDateSelected(selectedDate);
	}

	/**
	 * Used to set sidebar title bar
	 * @param  {Date}  date Current date
	 * @return {Boolean}      Is current date also the todays date
	 */
	function isTodaysDateSelected(date) {
		if(date === undefined) {
			date = selectedDate;
		}
		isTodaysDate.isTrue = DateUtility.getDateOnly(date).getTime() === DateUtility.getDateOnly(new Date()).getTime();
		return isTodaysDate;
	}

	return {
		getSelectedDate: getSelectedDate,
		setSelectedDate: setSelectedDate,
		isTodaysDateSelected: isTodaysDateSelected
	};
});