Use $global instead of $window for accessing window object