I have an array defined in slickgrid which captures the rows which are edited in the grid using OnCellChange event. I want to access this array in my angularjs Controller so that I can send the edited rows to backend. I have already searched for this question and I got to know that I need to use $window in my controller to access global js variable. But it's not working for me. I have read this How to access global js variable in AngularJS directive and this http://code.angularjs.org/1.1.5/docs/api/ng.$window
Infact in 2nd link(above) , many people have commented that it's didn't work for them either. Can anyone please tell me what am I missing?
Slick_grid.js
var editedRows = [];
grid.onCellChange.subscribe(function(e , args){
var item = args.item;
for( i=0;i<editedRows.length; i++)
{
if(item.employeeId == editedRows[i].employeeId)
{
editedRows.splice(i , 1 , item);
return;
}
else
{
editedRows.push(item);
return;
}
}
});
controller.js
myApp.controller('SubmitController' ,
['$scope' ,'$window', function($scope , $window) {
alert($window.editedRows);
$scope.editedRows = $window.editedRows;
}]);
I think the editedRows
may have been defined within a function scope (javascript) and hence not accesible outside.
If editedRows is your own variable you can try
window.editedRows = [];
Not a good solution though.