I used a directive to buildup database after ng-repeat finished:
app.directive('repeatDone', function() {
return function(scope, element, attrs) {
if (scope.$last) {
scope.$eval(attrs.repeatDone);
}
}
});
function InformationController($scope, $http) {
$http.get("people").success(function(response) {
$scope.people = response;
});
$scope.initDataTable = function() {
$('#employeeTable').DataTable({
});
};
};
<table class="table table-striped table-bordered table-hover" id="employeeTable">
<thead>
<tr>
<th>id</th>
<th>Name</th>
<th>Gender</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="result in people" repeat-done="initDataTable()">
<td>{{ result.id }}</td>
<td>{{ result.name }}</td>
<td>{{ result.gender }}</td>
</tr>
</tbody>
</table>
The data is displayed normally, but cannot use default sorting or searching.
Is there anything wrong? What should I do to enable the sorting and searching?