I am using Angular-datatable for showing data and its working fine with static data, but when if giving data dynamically its not working. Its taking my hard time.
What i want to achieve is to load data from
ajax
indatatable
.
This following code i am using for initialization, and its working fine Plunker:
function MyChapterController($scope, $q, DTOptionsBuilder, DTColumnBuilder, chapter) {
var vm = this;
vm.dtOptions = DTOptionsBuilder.newOptions()
.withPaginationType('full_numbers')
.withDisplayLength(2)
.withDOM('pitrfl');
vm.dtColumns = [
DTColumnBuilder.newColumn('id').withTitle('ID'),
DTColumnBuilder.newColumn('title').withTitle('First name'),
DTColumnBuilder.newColumn('lastName').withTitle('Last name').notVisible()
];
vm.myChapters = [];
}
This is following code not working check Plunker:
function MyChapterController($scope, $q, $resource, DTOptionsBuilder, DTColumnBuilder, chapter) {
var vm = this;
vm.dtOptions = DTOptionsBuilder.newOptions()
.withPaginationType('full_numbers')
.withDisplayLength(2)
.withDOM('pitrfl');
vm.dtColumns = [
DTColumnBuilder.newColumn('id').withTitle('ID'),
DTColumnBuilder.newColumn('title').withTitle('First name'),
DTColumnBuilder.newColumn('lastName').withTitle('Last name').notVisible()
];
vm.myChapters = [{
"id": 860,
"firstName": "Superman",
"lastName": "Yoda"
}, {
"id": 870,
"firstName": "Foo",
"lastName": "Whateveryournameis"
}, {
"id": 590,
"firstName": "Toto",
"lastName": "Titi"
}, {
"id": 803,
"firstName": "Luke",
"lastName": "Kyle"
}];
}
I have also tried with dataresource
Plunker but here also hard luck.
It already consumed my lot of time. So finally i decided to take advice from you all. Any help would be appreciated.
Showing 0 to 0 of 0 entries
and try to click on column all data will be gone. Why we are getting this issue. – Kristinakristine