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를 지정하려고합니다. 이 시나리오를 도와주세요.