Use  service $window instead of window object

Replace of window use by the use of window service