javascript - injection of $window in angular, what for? -


what use of $window injection angular ?

for instance ,

var mycontroller = function ($scope, $window) {     // window still available here }; mycontroller.$inject = ['$scope', '$window']; 

it known best practice avoid using global variables when possible. therefore, angular provides valid 'angular' way option window object inside code service. incredibly useful tests have option.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -