2
如果我在jquery事件中,我不知道如何訪問類變量。下面的示例如何訪問jquery事件內部的類變量?
/// <reference path="../typings/jquery/jquery.d.ts" />
export class Notes {
// i want to access this inside of the click event
test = "test";
foo() {
//works here
alert(this.test);
$("#testDiv").click(function() {
// context of this changes so this no longer works
alert(this.test);
//how do i access the test varible in here?
})
}
}