angularjs - Accessing variable defined in slickgrid in AngulaJs -
i have array defined in slickgrid captures rows edited in grid using oncellchange event. want access array in angularjs controller can send edited rows backend. have searched question , got know need use $window in controller access global js variable. it's not working me. have read how access global js variable in angularjs directive , http://code.angularjs.org/1.1.5/docs/api/ng.$window
infact in 2nd link(above) , many people have commented it's didn't work them either. can please tell me 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 editedrows
may have been defined within function scope (javascript) , hence not accesible outside.
if editedrows own variable can try
window.editedrows = [];
not solution though.
Comments
Post a Comment