0

I have a table that has multiple pages and a navigation to scroll through the pages. I have a function in my ng-click "refill_checkboxes" that should be executed after the next page is rendered but it is always executed first. How can I do it the right way?

<table>
    <thead>
        <th>Term</th>
        <th class="check">Check</th>
    </thead>
    <tr ng-repeat="term in data | slice:panel.offset:panel.offset+panel.size" ng-show="showMeta(term)" ng-attr-id="{{term.id}}">
        <td>{{term.label}}</td>
        <td><input type="checkbox" ng-click="switch_TermsCheck(term,this)" ng-attr-id="{{term.id}}" value="term" /></td>
    </tr>
</table>

<div>
    <i ng-click="panel.offset = (panel.offset + panel.size);refill_checkboxes(this);" ng-show="data.length > panel.offset+panel.size" class='icon-arrow-right pointer'></i>
</div>
1
  • Please let me know if my answer solved your problem by accepting it/commenting it :) Commented Nov 3, 2015 at 16:10

1 Answer 1

1

Javascript is single threaded and ng-click is executed in the correct order as far as I know. You can move your function call to the next tick this way :

Create a function :

//don't forget to include $timeout in your controller
$scope.goNext = function(that) {
    $scope.panel.offset = ($scope.panel.offset + $scope.panel.size);
    $timeout(function() {
        refill_checkboxes(that)
    }, 0);
};

<i ng-click="go
Next(this)" ng-show="data.length > panel.offset+panel.size" class='icon-arrow-right pointer'></i>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.