angularjs - How does $timeout cause the afterSelectionChange function to be called? -


i'm trying here enough info go fix problem, wanting understanding going on inside angular.

ng-grid has issues, lots of them, i've found "fix" 1 don't understand.

i have grid enough rows fills visible area. if click on different rows, afterselectionchange method called. if after clicking in grid move focus arrow keys, calls callback if grid scrolls.

so put in $timeout print out selected row every half second see if changing selected row , not calling callback, , fixed problem. every time move cursor keyboard, callback fires, though thing happening in callback $log.debug().

  1. is because $timeout causing happen within framework $apply or $digest?
  2. if that's case, why isn't keyboard causing happen?

edit: options @tassekatt

    $scope.callgridoptions = {         data: 'callrecords',         multiselect: false,         sortinfo: {fields:['starton'], directions:['asc']},         columndefs: [  ...         ],         afterselectionchange: $scope.oncallchange,         selecteditems: $scope.selectedcalls     }; 

in end, reduce timeout code this:

    function nggridfixer() {         // presence of timer causes nggrid correctly react up/down arrow , call         // afterselectionchange callback supposed to.         $timeout(nggridfixer, 500);     }     nggridfixer(); 

i put in rootscope because problem happens on pages of app.

$log part of angular framework, processed might execute watches laid down earlier. in other words calling $log.debug() print out structure, might running scope.$digest every half second, cause callback(s) fire. if take out inside $timeout function, or use console.log instead, callback(s) won't fire

a way semi-properly use ngkeydown.

edit: $timeout execute function in scope.$apply default. https://docs.angularjs.org/api/ng/service/$timeout (invokeapply). not aware of this. code calling scope.$apply every half second.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -