javascript - Ng-Repeat and ng-table issue -


i'm new angular js. below code not working. have tried data table ng-repeat. showing table without sorting, pagination option.

response data looks like:

[{     \"account_local\":\"9007\",\"company_id\":\"10001\",     \"account_global\":\"100001\",\"ic_partner\":\"9008\",     \"account_global_desc\":\"aus global\",     \"account_type\":\"1\",\"company_desc\":\"thirdrock\",     \"active\":true },         {     \"account_local\":\"9008\",\"company_id\":\"10001\",     \"account_global\":\"100001\",\"ic_partner\":\"9009\",     \"account_global_desc\":\"aus global\",     \"account_type\":\"1\",\"company_desc\":\"thirdrock\",     \"active\":true },{     \"account_local\":\"9014\",\"company_id\":\"10001\",     \"account_global\":\"100001\",\"ic_partner\":\"test\",     \"account_global_desc\":\"aus global\",     \"account_type\":\"1\",\"company_desc\":\"thirdrock\",     \"active\":true }, 

html file

<div ng-app="myapp" ng-controller="accountmappingctrl vm">    <table ng-table="vm.tableparams" show-filter="true" class="table">      <tr ng-repeat="accountmap in $data">        <td title="'ic_partner'" filter="{ ic_partner: 'text'}" sortable="'ic_partner'">          {{ accountmap.ic_partner }}        </td>        <td title="'account_global'" filter="{ account_global: 'text'}" sortable="'account_global'">          { accountmap.account_global }}        </td>      </tr>    </table>  </div>

js file:

var app = angular.module('myapp', [ 'ngtable']); app.controller('accountmappingctrl', ['$scope', '$http','$cookies', 'ngtableparams',  function($scope, $http, $filter, ngtableparams) {    $http.get("http://localhost:52087/api/accountmapping")     .then(function(response) {     var convertjson = angular.fromjson(response.data);     var self = this;     var data = convertjson;     self.tableparams = new ngtableparams({}, { dataset: data});     }); }); 

var myapp = angular.module('myapp',["ngtable"]);    //myapp.directive('mydirective', function() {});  //myapp.factory('myservice', function() {});    myapp.controller('myctrl',function($scope,ngtableparams){  	 $scope.name = 'superhero';     var data = [{      "account_local":"9007","company_id":"10001",      "account_global":"100001","ic_partner":"9008",      "account_global_desc":"aus global",      "account_type":"1","company_desc":"thirdrock",      "active":true  },          {      "account_local":"9008","company_id":"10001",      "account_global":"100001","ic_partner":"9009",      "account_global_desc":"aus global",      "account_type":"1","company_desc":"thirdrock",      "active":true  },{      "account_local":"9014","company_id":"10001",      "account_global":"100001","ic_partner":"test",      "account_global_desc":"aus global",      "account_type":"1","company_desc":"thirdrock",      "active":true  }]  //your http call here    $scope.tableparams = new ngtableparams({}, { dataset: data});  }) 
<div ng-app="myapp" ng-controller="myctrl">    hello, {{name}}!         <table ng-table="tableparams" show-filter="true" class="table">      <tr ng-repeat="accountmap in $data">        <td title="'ic_partner'" filter="{ ic_partner: 'text'}" sortable="'ic_partner'">          {{ accountmap.ic_partner }}        </td>        <td title="'account_global'" filter="{ account_global: 'text'}" sortable="'account_global'">          {{ accountmap.account_global }}        </td>      </tr>    </table>          </div>  <link rel="stylesheet"; href="https://unpkg.com/ng-table@2.0.2/bundles/ng-table.min.css">  <script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.2/angular.js"></script>  <script src="https://unpkg.com/ng-table@2.0.2/bundles/ng-table.min.js"></script>

there type in code { accountmap.account_global }} should {{ accountmap.account_global }}

i have made fiddle of test data. please check this fiddle , working fine.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -