Angular Part 2 : Create Products List And Call API In TS File | Create Ecommerce Angular Project

Softwaretechit
1 min readFeb 20, 2023

--

Read More:- https://softwaretechit.com/angular-part-2-create-products-list-and-call-api-in-ts-file-create-ecommerce-angular-project/

Angular Part 2 : Create Products List And Call API In TS File | Create Ecommerce Angular Project

In This List The Products Grid

getProductlist(){
let httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
}),
}
return this.http_service.get(this.base_url+"product",httpOptions)
}
getlimitProductlist(limit:number){
let httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
}),
}
return this.http_service.get(this.base_url+"product?limit="+limit,httpOptions)
}
import { Component, OnInit,Input } from "@angular/core";
import { Router } from "@angular/router";
import { Subscriber } from "rxjs";
import { ProductModel } from "../models/product.model";
import { CartService } from "../services/cart.service";
import { ProductService } from "../services/product.service";
@Component({
selector:"product-component",
templateUrl:'./product.component.html',
styleUrls:["product.component.css"],

})
export class ProductComponent implements OnInit{

product_list:ProductModel[]=[];
category='laptop';
constructor(private product_httpservice:ProductService,private http_Cart:CartService,private router:Router){
}
ngOnInit(): void {
this.product_httpservice.getProductlist().subscribe((data)=>this.product_list=data['result'])

}
}

You May Also Like

Originally published at https://codeproductaffiliate.medium.com on February 20, 2023.

--

--