我有一个名为abc的组件,并且在该组件中有三个名为title,Desc,Name的变量,当我尝试从嵌套函数访问它时,它给了我未定义的含义。
例如
@Component({
selector: 'abc',
templateUrl: './abc.component.html',
styleUrls: ['./abc.component.css'],
providers: [abcService]
})
export class abcComponent implements AfterViewInit,AfterViewChecked {
title;
Desc;
Name;
date=null;
test(){
this.title='a';
//work fine
}
test11(){
$('#cmg tbody').on('click', 'a.editor_edit', function (e) {
e.preventDefault();
this.title= false; //gives me an undefined
});
}
}
Run Code Online (Sandbox Code Playgroud)