简体   繁体   中英

AngularJS, ng-grid won't load data when using setTimeout() and pagination

I'm trying to use Ng-Grid with pagination option. I am able to display data in grid, format them, etc.

My controller: http://pastebin.com/mnHE0rYq

The problem appears when I am trying to configure pagination. When using code like below, no data is rendered in table, but I know $scope.myData has data loaded (checked variable in console).

When I comment out $timeout function in $scope.getPagedDataAsync function ( I also tried setTimeout() - the same behaviour) I can see data in grid, but grid is not reloading after clicking next/previous page. Also, I noticed that $scope.$apply() is never called.

My Ng-Grid version is 2.0.11 and AngularJS is 1.2.16.

Thanks for help!

If anyone face the same issue, the problem was really trivial and appears in HTML line (I didn't add this line to post, but I couldn't imagine there might be any problem):

 <div ng-controller="MyCtrl" class="gridStyle" ng-grid="gridOptions" ></div>

I found out ng-controller can't be in the same tag with ng-grid.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM