グリッドにコンテキストメニュー項目を追加するには、文書hereに従っています。問題は、getContextMenuItems(この例では)のスコープから、コンポーネント内の他のメソッドや変数にアクセスできないということです。これは可能ですか?以下の例:コンテキストメニューを使用してスコープを設定する
private varIWantToAccess: boolean = false;
function getContextMenuItems(params) {
var result = [
{ // custom item
name: 'Alert ' + params.value,
action: function()
{
window.alert('Alerting about ' + params.value);
this.varIWantToAccess = true; // Builds fine, but throws a run time exception, since this "this" context is different than the one that has "varIWantToAccess"
}
},
....
return result;
}
ありがとう!
をコンテキストを渡します。同様の問題:[参照が範囲外であるため、角5/4/2メソッドが渡されました](https://stackoverflow.com/questions/48557364/1417185) – Paritosh
[角度5/4/2のメソッドが重複している可能性があります。範囲外](https://stackoverflow.com/questions/48557364/angular-5-4-2-method-passed-as-reference-is-not-in-scope) – Paritosh