javascript - Why is 'window.angular' used like so, in this function definition? -


i'm trying understand angularjs file need use integrate django, , has weird syntax i'm not familiar (bear in mind i'm junior dev, may bread , butter)...

it goes like:

(function(angular, undefined){     'use script';     var djng_forms_module = angular.module('ng.django.forms', []);     funtion hascode(s){         return .....     }     var foo = ..... }(window.angular)); 

i've seen this javascript concept of window , shows window part top (?) level object browser creates when loads page.

running console.log(window.angular) prints out load of internal angular stuff. i'm guessing internal guts of angularjs...?

but why weird encapsulation function (something javascript being 'functional' language)?

the full script here , can't figure out why uses window.angular in function definition (as opposed normal way of doing things). seems set means it's not working application when import via script tags.

window.angular global angularjs variable created once angularjs has been loaded script tag. code fragment have pasted ensures executed after population of variable. 1 reason might written in verbose way auto-generated nature. in wider context, may have implication order in scripts executed or using different versions of angularjs library.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -