You can construct your table the "angular" way, eg using the directive ng-repeat
on tr
tag.
All you need to do is to add the directive datatable
with the value ng
on your table in order
to make it rendered with DataTables.
Note:
- If you use the Angular way of rendering the table along with the Ajax or the promise solution, the latter will be display.
-
Don't forget to set the properties
ng
in the directivedatatable
in order to tell the directive to use the Angular way!
The "Angular way" is REALLY less efficient than fetching the data with the Ajax/promise solutions. The lack of
performance is due to the fact that Angular add the 2 way databinding to the data, where the ajax and promise solutions
do not. However, you can use Angular directives (ng-click
, ng-controller
...) in there!
If your DataTable has a lot of rows, I STRONGLY advice you to use the Ajax solutions.
With Angular v1.3, the one time binding can help you improve performance.
If you are using angular-resource, then you must resolve the promise and then set to your $scope
in order to use the one time binding
.