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

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -