0

I have my html table as below:

<div>
  <table datatable="" class="table table-condensed" id="listTable">
    <thead>
      <tr>
        <th>NAV ID</th>
        <th>NAV DATE</th>
        <th>DESCRIPTION</th>
        <th>AMOUNT</th>
        <th>ADMIN FEE</th>
        <th>PURCHASE PRICE</th>
        <th>POSTED BY</th>
      </tr>
    </thead>
    <tbody>
      <tr ng-repeat="navs in navs">
        <td>{{navs.NAV_ID}}</td>
        <td>{{navs.NAV_DATE}}</td>
        <td>{{navs.DESCRIPT}}</td>
        <td>{{navs.AMOUNT}}</td>
        <td>{{navs.ADMIN_FEE}}</td>
        <td>{{navs.P_PRICE}}</td>
        <td>{{navs.STAFFNAME}}</td>
      </tr>
    </tbody>
  </table>
</div>

and I have the js script to render the data in my html table. How can i use datatables plugins and the js file. i use the script below too load the values into my html page. the values are loaded well but i am stuck when it comes to displaying the data in a datatable

 angular.module('CrudApp', []).
 config(['$routeProvider',
   function($routeProvider) {
     $routeProvider.
     when('/', {
       templateUrl: 'assets/templates/list.html',
       controller: ListCtrl
     }).
     when('/addNavs', {
       templateUrl: 'assets/templates/addNewNav.html',
       controller: AddCtrl
     }).
     otherwise({
       redirectTo: '/'
     });
   }
 ]);

 function ListCtrl($scope, $http) {
   $http.get('api/getnavs').success(function(data) {
     $scope.navs = data;

   });
 }
3
  • Welcome to stackoverflow.. Are you creating custom directive, if so please share that code too. Commented Jul 10, 2015 at 10:34
  • Thank you. am not creating a custom directive. Commented Jul 10, 2015 at 10:39
  • ng-repeat="navs in navs" - shouldnt that be "nav in navs"? Commented Nov 30, 2016 at 11:16

2 Answers 2

0

You have to write a back-end web services services which will directly communicate with the databases.

$http.get('api/getnavs').success(function(data) { $scope.navs = data;

});

By using this services calls retrieve data from server. you cannot access databases using front end programming languages like angular JS.

But there are opportunities for front end databases like pouch DB .

Sign up to request clarification or add additional context in comments.

2 Comments

I have a back-end web service that fetches the data from the database. I can display the data on the HTML table but having the data in jquery datatables giving me a hard time.
0

thank you all for your answers, they gave me great ideas to work around the task. i managed to figure out how to do it. I got an idea from this and i managed to come up with this code that worked for me. Hope it helps someone with the same problem app.controller('withOptionsCtrl', withOptionsCtrl); function withOptionsCtrl($scope, DTOptionsBuilder, DTColumnDefBuilder){

$scope.dtOptions = DTOptionsBuilder.newOptions()
    .withPaginationType('full_numbers')
    .withDisplayLength(5)
    .withDOM('pitrfl');
$scope.dtColumnDefs=[
DTColumnDefBuilder.newColumnDef(0),
DTColumnDefBuilder.newColumnDef(1).notVisible,
DTColumnDefBuilder.newColumnDef(2).notVisible,
DTColumnDefBuilder.newColumnDef(3).notVisible,
DTColumnDefBuilder.newColumnDef(4).notVisible,
DTColumnDefBuilder.newColumnDef(5).notVisible,
DTColumnDefBuilder.newColumnDef(6).notVisible
];

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.