我如何定义/注入以允许使用&在我的Angular应用中尝试运行GA(谷歌分析代码)时,清除我的$window
文件中未定义的js/app.js
错误。
错误:' $窗口未定义'
.run(function($rootScope, APIServer, social, $location, music, $anchorScroll, $routeParams) {
// $window.ga('create', 'UA-55555555-5', 'auto'); <-- here
/*
* Scroll down to comments if available
*/
$anchorScroll.yOffset = 70;
//when the route is changed scroll to the proper element.
$rootScope.$on('$routeChangeSuccess', function(newRoute, oldRoute) {
// $window.ga('send', 'pageview', $location.path()); <-- here
$location.hash($routeParams.scrollTo);
$anchorScroll();
});
答案 0 :(得分:2)
也可以注入$ window。
.run(function($rootScope, APIServer, social, $location, music, $anchorScroll, $routeParams, $window) {
// $window.ga('create', 'UA-55555555-5', 'auto'); <-- here
/*
* Scroll down to comments if available
*/
$anchorScroll.yOffset = 70;
//when the route is changed scroll to the proper element.
$rootScope.$on('$routeChangeSuccess', function(newRoute, oldRoute) {
// $window.ga('send', 'pageview', $location.path()); <-- here
$location.hash($routeParams.scrollTo);
$anchorScroll();
});