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