I am currently working on integrating ngTable with AngularJS.
After successfully installing all necessary Angular dependencies, everything seems to be functioning well.
However, I am encountering an issue where my HTTP GET request is not triggering as expected when using ngTable.
Could someone kindly point out what might be missing in my code?
Here is the code snippet in question:
angular.module('clinang', ['ngTable']).controller('pacientesCtrl', function($scope,$http,NgTableParams){
this.tableParams = new NgTableParams({
page: 1,
count: 10
}, {
getData: function($defer, params) {
$http.get('/getdadospac/?oper=S', {params: {
pageNumber:params.page() - 1,
rangeStart:rangeStart,
rangeStop:rangeStop}})
.then(function(data, status) {
params.total(data.results.total);
$defer.resolve(data.results);
});
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<link rel="stylesheet"; href="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7c121b51081d1e10193c4e52">[email protected]</a>/bundles/ng-table.min.css">
<script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0b656c267f6a69676e4b3925">[email protected]</a>/bundles/ng-table.min.js"></script>
<body ng-app="clinang">
<div ng-controller="pacientesCtrl">
<a class='btn btnprimary' href='/getdadospac/?oper=S' >Button</a>
<table ng-table="vm.tableParams" class="table" show-filter="true">
<tr ng-repeat="paciente in $data">
<td title="'Pront'" filter="{ name: 'text'}" sortable="'pront'">
{{paciente.pront}}</td>
<td title="'Nome'" filter="{ age: 'number'}" sortable="'nome'">
{{paciente.nome}}</td>
</tr>
</table>
</div>
</body>