26 lines
762 B
TypeScript
26 lines
762 B
TypeScript
import { HttpClient } from '@angular/common/http';
|
|
import { Component, OnInit } from '@angular/core';
|
|
import { IPagination } from './models/pagination';
|
|
import { IProduct } from './models/product';
|
|
|
|
@Component({
|
|
selector: 'app-root',
|
|
templateUrl: './app.component.html',
|
|
styleUrls: ['./app.component.scss']
|
|
})
|
|
export class AppComponent implements OnInit {
|
|
title = 'E-Commerce';
|
|
products: IProduct[];
|
|
|
|
constructor(private http: HttpClient) {}
|
|
|
|
ngOnInit(): void {
|
|
this.http.get('https://localhost:5001/api/products?pageSize=50').subscribe(
|
|
{
|
|
next: (response: IPagination) => { this.products = response.data; },
|
|
error: (e: any) => { console.log(e); },
|
|
complete: () => { console.log('complete'); }
|
|
}
|
|
);
|
|
}
|
|
} |