2015-10-30 35 views
0

我有一个表格,它有多个页面和一个导航来滚动页面。我有一个函数,在我单击“refill_checkboxes”时应该在下一个页面呈现后执行,但它总是首先执行。我该如何正确地做到这一点?ng键功能以错误的顺序执行

<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> 
+0

请让我知道,如果我的回答,接受它/发表评论它解决你的问题:) – IggY

回答

1

据我所知,Javascript是单线程和ng-click按正确顺序执行的。您可以将您的函数调用移动到下一个节拍是这样的:

创建一个函数:

//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>