Last active
August 29, 2015 14:18
-
-
Save darwinrc/e3329c0f05670d322cb7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//bow.js | |
| |
var bow = bow || {}; | |
(function () { | |
bow.tablas = bow.tablas || {}; | |
bow.fechas = bow.fechas || {}; | |
/** | |
* Método encargado de paginar los registros de una tabla | |
* | |
* @param datos. Arreglo con los datos a paginar | |
* @param limite. Cantidad de filas por página | |
* @param inicial. Posición inicial del cursor de paginación (página inicial a mostrar) | |
* @return Objeto para utilizar en las etiquetas <pagination> y <ng-repeat> | |
*/ | |
bow.tablas.paginar = function (datos, limite) { | |
var paginacion = { | |
totalFilas: datos.length, | |
filasPorPagina: limite, | |
paginaInicial: 1, | |
paginaActual: 1, | |
filasMostrar: datos, | |
pageChanged: function () { | |
var inicio = ((this.paginaActual - 1) * this.filasPorPagina); | |
var fin = inicio + this.filasPorPagina; | |
this.filasMostrar = datos.slice(inicio, fin); | |
return this.filasMostrar; | |
} | |
}; | |
paginacion.pageChanged(); | |
return paginacion; | |
}; | |
})(); | |
//usage | |
zonificacionService.getPaises().success(function (data) { | |
vm.paises = bow.tablas.paginar(data.paises, 10); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment