ng-table icon indicating copy to clipboard operation
ng-table copied to clipboard

Json input

Open Prideth opened this issue 12 years ago • 2 comments

an example with json input from an url and not array would be nice

Prideth avatar Sep 02 '14 18:09 Prideth

@prideth you mean a JSON api ? If so, that is what I am using and I had to do a few specific things.

I use a service to retrieve from the JSON api so I did

var data = loadBundles;

The problem is, though, that because of the delay in retrieving the data from the API, the table shows up blank until you click on the items perpage links at the bottom to refresh the table.

The way I fixed this, and I realize it is kind of hacky but it works for me is:

$timeout(function(){
        $scope.tableParams.reload();
    }, 500);

After 500ms it runs the reload() on tableParams and it's good to go.

My case is special because it isn't going to be hosted on the web but for future reference I would like to know of a better way to do this besides raising the timeout delay.

I had a $watch on the data and $scope.TableParams but it threw exceptions about going through 10 iterations of the watch function. I had that reload statement inside the watch. It worked but threw a lot of errors. Doing it this way doesn't throw those errors.

realityfluxstudios avatar Sep 05 '14 09:09 realityfluxstudios

After hours trying I found a way that works quite well, but I had to rewrite my whole service to get it work

var data = DemoService.query(); data.$promise.then(function (data) { $scope.tableParams = new ngTableParams({

Prideth avatar Sep 18 '14 14:09 Prideth