Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component } from '@angular/core';
- import { NavController } from 'ionic-angular';
- import { RestApiProvider } from '../../providers/rest-api/rest-api';
- @Component({
- selector: 'page-home',
- templateUrl: 'home.html'
- })
- export class HomePage {
- data: any;
- produtos: string[];
- errorMessage: string;
- page = 1;
- perPage = 0;
- totalData = 0;
- totalPage = 0;
- constructor(public navCtrl: NavController, public restApi: RestApiProvider) {
- this.getProdutos();
- }
- getProdutos() {
- this.restApi.getprodutos()
- .subscribe(
- res => {
- this.data = res;
- this.produtos = this.data.data;
- this.perPage = this.data.per_page;
- this.totalData = this.data.total;
- this.totalPage = this.data.total_pages;
- },
- error => this.errorMessage = <any>error);
- }
- doInfinite(infiniteScroll) {
- setTimeout(() => {
- this.restApi.getprodutos()
- .subscribe(
- res => {
- this.data = res;
- this.perPage = this.data.per_page;
- this.totalData = this.data.total;
- this.totalPage = this.data.total_pages;
- for(let i=0; i<!!...++= {
- this.produtos.push(this.data.data[i]);
- }
- },
- error => this.errorMessage = <any>error);
- console.log('Async operation has ended');
- infiniteScroll.complete();
- }, 1000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement