javascript - $window error '$window not defined' with google analytics code in Angular app -


how define / inject allow use & clear error of $window not defined in js/app.js file, when trying run ga (google analytics code) in angular app.

error: '$window not defined'

   .run(function($rootscope, apiserver, social, $location, music, $anchorscroll, $routeparams) {          // $window.ga('create', 'ua-55555555-5', 'auto'); <-- here          /*          * scroll down comments if available          */         $anchorscroll.yoffset = 70;         //when route changed scroll proper element.         $rootscope.$on('$routechangesuccess', function(newroute, oldroute) {             // $window.ga('send', 'pageview', $location.path()); <-- here             $location.hash($routeparams.scrollto);             $anchorscroll();           }); 

inject $window too.

.run(function($rootscope, apiserver, social, $location, music, $anchorscroll, $routeparams, $window) {          // $window.ga('create', 'ua-55555555-5', 'auto'); <-- here          /*          * scroll down comments if available          */         $anchorscroll.yoffset = 70;         //when route changed scroll proper element.         $rootscope.$on('$routechangesuccess', function(newroute, oldroute) {             // $window.ga('send', 'pageview', $location.path()); <-- here             $location.hash($routeparams.scrollto);             $anchorscroll();           }); 

Comments