Skip to content Skip to sidebar Skip to footer

Passing Java Script Function Result To Angular Ng-table

I have Angular ng-table where I load Json data to $data variable and display in the table. function ngTable(){ var app = angular.module('main', ['ngTable']). controller('DemoCtrl',

Solution 1:

Simple assignment will work, but remember to reload the grid:

$scope.loadData = function () {
  $scope.data = $scope.ReturnJson();
  $scope.tableParams.reload();
}

$scope.ReturnJson = function () {
  var json = [{name: "bb", age: 200},{name: "aaa", age: 100}];
  return json;
}

Here is a working demo: http://plnkr.co/edit/Jw41uCmHGAfjkuoLIQor?p=preview


Post a Comment for "Passing Java Script Function Result To Angular Ng-table"