0
forループを使用してgridOptionを作成し、onRegisterApiをバインドする状況があります。しかし、onRegisterApiメソッドのループ変数はループ変数を超えています。コードスニペットは次のようになります。angularJS UIグリッドのforループ内でgridOptionに対してonRegisterApiをバインドします。
for(var k=0; k<3; k++){
$scope.gridOptions[k] = {
data : $scope.gridData[k],
enableCellEditOnFocus : true,
columnDefs : $scope.colmDef[k],
onRegisterApi : function(gridApi){
console.log(k) // here value of k is always 2.
$scope.gridApi[k] = gridApi;
console.log(k) // here value of k is always 3.
$scope.gridApi[k].edit.on.afterCellEdit($scope, function(rowEntity, colDef, newValue, oldValue){
console.log(k) // here value of k is always 3.
/* I want to handle celledit of specific grid from gridApi. But this is not working as the variable 'k' doesn't change according to loop and it will be fixed always.*/
})
}
}
}
したがって、gridOptionsのループでonRegisterApiを割り当てたいとします。このシナリオで私を助けてください。