I am trying to add pagination to my table by following this link:
https://ng-bootstrap.github.io/#/components/table/examples (under Pagination).
The problem is that I'm getting an error on map(product,i)..; this is the error:
- Property 'map' does not exist on type 'typeof Product'.
- Parameter 'product' implicitly has an 'any' type.
- Parameter 'i' implicitly has an 'any' type.
Will you kindly help me? Thank you all.
import { Product } from '../product';
import { Observable, Subject } from "rxjs";
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import {map} from 'rxjs/operators';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
@Component({
selector: 'app-product-list',
templateUrl: './product-list.component.html',
styleUrls: ['./product-list.component.css']
})
export class ProductListComponent implements OnInit {
constructor(private productservice: ProductService, private fb: FormBuilder, private modalService: NgbModal) {}
productsArray: any[] = [];
dtTrigger: Subject<any> = new Subject();
products: Product[] = [];
product: Product = new Product();
productlist: any;
page = 1;
pageSize = 4;
collectionSize = Product.length;
ngOnInit() {
this.productservice.getProductList().subscribe(data => {
console.log(data)
this.products = data;
this.dtTrigger.next();
})
this.editProfileForm = this.fb.group({
productcode: [''],
name: ['']
});
this.refreshProduct();
}
refreshProduct() {
this.products = Product
.map((product: any, i: number) => ({id: i + 1, ...product}))
.slice((this.page - 1) * this.pageSize, (this.page - 1) * this.pageSize + this.pageSize);
}
.
.
}