Use angular service instead of window object