小编Ank*_*ara的帖子

无法从angular4中的嵌套函数访问此函数

我有一个名为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)

javascript jquery angular2-services angular angular5

2
推荐指数
1
解决办法
1178
查看次数