Angular 如何通过http get向服务器发送参数

Angular 如何通过http get向服务器发送参数,angular,http,kendo-ui,telerik,Angular,Http,Kendo Ui,Telerik,我正在尝试学习asp.NETRESTAPI和KendoUI。一切都很好,但我希望通过向API发送take和skip作为Get参数来进行服务器端分页 这是我对API get方法的实现: public ResaultPage GetProducts(int skip =1, int take=20) { ResaultPage rp = new ResaultPage(); var count= db.Products.Count<

我正在尝试学习asp.NETRESTAPI和KendoUI。一切都很好,但我希望通过向API发送take和skip作为Get参数来进行服务器端分页

这是我对API get方法的实现:

       public ResaultPage GetProducts(int skip =1, int take=20)
          {
       ResaultPage rp = new ResaultPage();
       var count= db.Products.Count<Product>();

        rp.count = count;
        IPagedList<Product> x = db.Products.OrderBy(s => 
         s.CategoryID).ToPagedList<Product>(skip, take);
        foreach (Product v in x)
        {
            rp.pr.Add(v);
        }

        return rp;}
当我运行该应用程序时,我在同一页面中获得了前20条记录,其中有(1,2)个分页 当我点击2时,我仍然得到相同的结果

例如,我只需要每页获得10个,第2页中的其他10个


其中skip的剑道Ui属性=1,take的剑道Ui属性=10

在url之后,您需要传递另一个名为
options
的对象,该对象包含参数。您可以使用HttpParams发送参数

getProducts1(skip:any, take:any ): Observable<ResaultPage> {
     let myparams = new HttpParams(); 
     myparams.set('Skip', skip);  
     myparams.set('Take', take); 
     return this.http.get<ResaultPage>(this.productsUrl,{params:myparams})
  .pipe(
    tap(data => console.log(JSON.stringify(data))),
    catchError(this.handleError)

     );
      }
getProducts1(跳过:任意,获取:任意):可观察{
设myparams=newhttpparams();
myparams.set('Skip',Skip);
myparams.set('Take',Take);
返回this.http.get(this.productsUrl,{params:myparams})
.烟斗(
点击(data=>console.log(JSON.stringify(data)),
catchError(this.handleError)
);
}

谢谢你的回答,但不幸的是我还是遇到了同样的问题
         public pageChange(event: PageChangeEvent): void {
            this.gridState.skip = event.skip+10;


          this.productService.getProducts1(this.gridState.skip,
        this.gridState.take).subscribe(
           sub  => {
        this.totalCount=sub.count;
       this.products=sub.pr;
          console.log(this.products);

         });
getProducts1(skip:any, take:any ): Observable<ResaultPage> {
     let myparams = new HttpParams(); 
     myparams.set('Skip', skip);  
     myparams.set('Take', take); 
     return this.http.get<ResaultPage>(this.productsUrl,{params:myparams})
  .pipe(
    tap(data => console.log(JSON.stringify(data))),
    catchError(this.handleError)

     );
      }