Consider the snippet in Javascript,
var objt = {
fn : function(three, four){
four(); // window as (this === window)
}
}
objt.fn(3, function(){
alert(this); // window as (this === window)
});
The above is not a constructor function. Inside a function, the value of this depends on how the function is called. The function
function(){
alert(this);
}
was passed as an argument and as such wasn't linked to the objt. No issues with this.
Now consider the snippet in AngularJS regarding module and controller,
myModule.controller('MainCtrl', function(x1, x2) {
var main = this;
alert(this === window); // alert false, why and what is this here?
});