我是新手,我有一个 HTTPclient 服务,它从一个 JSON 文件中获取所有数据,有 1000 个寄存器,我如何进行分页,例如,显示前 10 个并对其进行分页
这是我的服务
@Injectable({
providedIn: 'root'
})
export class ProductsService {
constructor(private http:HttpClient ) {
}
getPorducts(): Observable<Product[]> {
return this.http.get<Product[]>('assets/data/DATA.json');
}
}
Run Code Online (Sandbox Code Playgroud)
我只是在我的家庭组件上使用它
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styles: []
})
export class HomeComponent implements OnInit {
public products: any[] = [];
constructor(private _Products: ProductsService) { }
public lastKey: any[] = [];
ngOnInit() {
this._Products.getPorducts().subscribe(data => {
if (data) {
this.products = data;
}
});
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到呢?提前致谢