According to the developer's guide, I should have access to the browser window from inside Angular c expressions $window.
Unlike JavaScript, where the default names correspond to global window properties, Angular expressions must use $ window to refer to the global window object. For example, if you want to call alert (), which is defined in a window, you must use $ window.alert () in the expression.
However, I cannot access $windowfrom the expressions evaluated with $scope.$eval. Here are some results that I get when I exit the console:
console.log($window);
console.log($scope.$eval('$window'));
console.log($scope.$eval('1+1'));
console.log($scope.$eval('scopeVar'));
The controller has $windowboth a dependency. I can access scope variables and other services from expressions, but not $window, so $scope.$eval($window.alert())it doesn't work either.
What am I missing here?
source
share