jQuery(this).closest('li').attr('id')
の結果をAngular 2 Typescriptの変数に格納します。jqueryからアクセスされた要素idを角2の変数に格納する方法Typescript
export class DashboardComponent implements OnInit {
angVariable: any;
ngOnInit() {
jQuery(this.elRef.nativeElement).on("click", "li a", function() {
/* I want to store this query result to Angular typescript
variable say angVariable and query is
"jQuery(this).closest('li').attr('id');"
basically I want to store Id of clicked li a into
angular 2 typescript variable angVariable
*/
});
}
somefunction() { // I will use angVariable here
}
}
は、ここにコードを入力
どのように私はそれを行うことができますか?
は私ができるように、どのような方法がありますjscriptで条件を満たすことに基づいて、typescript変数をtrueまたはfalseに設定します。 –