0

Hi I am working on Angularjs Datatables and trying to iterate the columns and rows using ng-repeat but its not working. I checked the document but not able to find the exact way to pass columns and records on html.

function CustomElementCtrl(DTOptionsBuilder, DTColumnBuilder) {  
    var vm = this;  
    vm.dtOptions = DTOptionsBuilder.fromSource('data.json')  
        .withDOM('<"custom-element">pitrfl');  
    vm.dtColumns = [  
        DTColumnBuilder.newColumn('id').withTitle('ID'),  
        DTColumnBuilder.newColumn('firstName').withTitle('First name'),
        DTColumnBuilder.newColumn('lastName').withTitle('Last name').notVisible()
    ];
}
Here the dtColumns are manually created and the dtOptions are directly assigned from json, but I want to assign columns also from json.
And why I can't use ng-repeat on html to iterate both columns and rows
rather then like this <table datatable="" dt-options="showCase.dtOptions"   dt-columns="showCase.dtColumns" class="row-border hover">


Thanks,

2
  • where you have used ng-repeat? and where have you assigned data to scope? Commented Apr 25, 2016 at 6:10
  • @KishoreBarik On html like <table datatable="" class="row-border hover"> <thead><tr><th ng-repeat="column in columns">{{column}}</th></tr></thead> <tbody><tr ng-repeat="record in records"><td>{{record.name}}</td><td>{{record.date}}</td></tr></tbody></table> and on controller $scope.columns = resoponse.data; $scope.records = response.data; Commented Apr 25, 2016 at 6:23

1 Answer 1

0

If you want to use the Angular way to bind the date your table must be like this

<table datatable="ng" class="row-border hover"></table>

as per docs.

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

2 Comments

Welcome to SO! When posting solutions to people's questions, it is important to include all the information in any link you include
@MayorMonty What do you mean by all the information ?

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.