In TypeScript, the this
inside a lambda doesn't have the traditional behavior of this
in JavaScript. If you look at the compiled JS it will be clear what's happening, but basically it will usually be a level higher than you'd expect - in your case the window object.
The easiest way to work around this is to do a var self=this;
above the line with the comment and then reference self
in your lambda, or else just use normal function syntax such as function(modal) {
which preserves the traditional functionality of this
from JS.
Dan Quirk answered a similar question that I had here: https://typescript.codeplex.com/workitem/1655
You may also wish to take a look at this: Can I access the other this in a TypeScript lambda?