title: Loading JSON via AJAX with NgTable parameters
body: <p>I'm trying to use ngTables to sort and filter data using an AJAX call. Currently I am able to replicate the data with an ng-repeat, but none of my sorting functions apply. I referenced this example <a href="http://plnkr.co/edit/zuzcma?p=info">http://plnkr.co/edit/zuzcma?p=info</a> and was able to get it to work using a mock.js file, but right now I'm using a file that I loaded onto my webserver and I can't seem to get it to work.</p>
  
  <p>I'm sure the answer is fairly simple and appreciate any help. I've attached my markup to show you what my controller and html file look like. Thank you all and let me know if you need anymore information!</p>
  
  <p>Here are some links to the API I am referencing. </p>
  
  <p><a href="http://bazalt-cms.com/ng-table/">http://bazalt-cms.com/ng-table/</a></p>
  
  <p><a href="http://bazalt-cms.com/ng-table/example/6">http://bazalt-cms.com/ng-table/example/6</a></p>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;div ng-controller="myController"&gt;
    &lt;table ng-table="tableParams" show-filter="true" class="table table-condensed"&gt;
      &lt;tr ng-repeat="user in data"&gt;
        &lt;td data-title="foo" sortable="foo"&gt;{{user.foo}}&lt;/td&gt;
        &lt;td data-title="bar" sortable="bar"&gt;{{user.bar}}&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>var app = angular.module('app', ['ngTable']);
  
  app.controller('myController', function($scope, $http, $filter, ngTableParams) {
  
   $http.get('http://jsondata.com/myjson.json')
    .success(function(data, status) {
      $scope.data = data;
    });
  
  $scope.tableParams = new ngTableParams({
      page: 1,            // show first page
      count: 10,          // count per page
      sorting: {
          foo: 'asc'     // initial sorting
      }
  }, {
      total: data.length, // length of data
      getData: function($defer, params) {
          // use build-in angular filter
          var orderedData = params.sorting() ?
                              $filter('orderBy')(data, params.orderBy()) :
                              data;
  
          $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
      }
    });
  });
  </code></pre>