I appeal to you because I have a problem with an infinite scroll, I managed to implement one for all products that is ok, but when implementing one for a product by category type (the category receives the type) I can not get it to work or it loads 10 to me and it repeats them to me again that with the answer of the servant I assigned it to an arrangement.
But if I make a .push to the arrangement with what comes in the data it works excellent but to the categories that have less than 10 products it tells me that the array is empty.
Sorry to bother you but it took several weeks and I do not succeed.
Thanks in advance
my services
cargaPorCategoria ( categoria: number ) {
this.tipCategoria = categoria;
let promesa = new Promise ( (resolve, reject)=>{
//let url = `${ URL_SERVICIOS }/registro/obtenerPorTipo/${ categoria }`;
let url = URL_SERVICIOS + "/productos/obtenerPorTipo/" + categoria + "/" + this.pagina; //Obtengo el url
//Peticion del servicio
this.http.get( url ).subscribe ( res => {
//console.log(res);
if ( res['error'] ) {
//Aquí tenemos un error
}
else{
//Creamos nueva data le pasamos los productos y el ancho que la queremos en este caso sería en 2 columnas
//let nuevaData = this.agrupar( res['productos'], 2 );
//this.Porcategorias = this.Porcategorias.concat(...res['productosPorCategoria']);;
this.Porcategorias.push(...res['productosPorCategoria']);//Aqui tendría que reemplazar "res['productos']" por la "nuevaData" para que se dibujaran en 2 columnas
console.log("Este es...")
console.log(this.Porcategorias)
console.log(this.pagina)
}
this.pagina += 1;
//this.pagina ++;
})
resolve();
})
return promesa;
}
my code
/******************************* Inicio Scroll infinito **************/
productoscroll( infiniteScroll ) {
this.prodProv.cargaPorCategoria( this.categoria.idCat )
.then( ()=>{
setTimeout(() => {
infiniteScroll.complete();}, 800);
} )
}
/ Fin Scroll infinito *********************************************/