Added Models

This commit is contained in:
Charles Showalter 2022-05-12 15:07:23 -07:00
parent 6e54a7b3aa
commit 9e53885330
13 changed files with 94 additions and 7 deletions

View File

@ -1,3 +1,9 @@
<h1>Welcome to {{title}}!</h1>
<i class="fa-brands fa-airbnb"></i>
<h2>test</h2>
<app-nav-bar></app-nav-bar>
<div class="container" style="margin-top: 140px;">
<h1>Welcome to {{title}}</h1>
<ul>
<li class="list-unstyled" *ngFor="let product of products">
{{product.name}}
</li>
</ul>
</div>

View File

@ -1,10 +1,26 @@
import { Component } from '@angular/core';
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 {
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'); }
}
);
}
}

View File

@ -1,18 +1,22 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule } from '@angular/common/http';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NavBarComponent } from './nav-bar/nav-bar.component';
@NgModule({
declarations: [
AppComponent
AppComponent,
NavBarComponent
],
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
HttpClientModule
],
providers: [],
bootstrap: [AppComponent]

View File

@ -0,0 +1,8 @@
import { IProduct } from "./product"
export interface IPagination {
pageIndex: number
pageSize: number
count: number
data: IProduct[]
}

View File

@ -0,0 +1,9 @@
export interface IProduct {
id: number
name: string
description: string
price: number
pictureUrl: string
productType: string
productBrand: string
}

View File

@ -0,0 +1,17 @@
<div class="d-flex flex-column flex-md-row align-items-center justify-content-between p-3 px-md-4 mb-3 bg-white border-bottom shadown-sm fixed-top">
<img src="/assets/images/logo.png" style="max-height: 70px;" alt="logo">
<nav class="me-3 my-md-0 mr-md-3 text-uppercase" style="font-size: larger;">
<a class="me-3 py-2 text-dark" href="#">Home</a>
<a class="me-3 py-2 text-dark" href="#">Shop</a>
<a class="me-3 py-2 text-dark" href="#">Contact</a>
</nav>
<div class="d-flex align-items-center">
<a class="position-relative">
<i class="fa fa-shopping-cart fa-2x me-3 text-dark"></i>
<div class="cart-no">5</div>
</a>
<a class="btn btn-outline-secondary me-3" href="#">Login</a>
<a class="btn btn-outline-secondary me-3" href="#">Sign up</a>
</div>
</div>

View File

@ -0,0 +1,12 @@
.cart-no {
position: absolute;
min-height: 25px;
min-width: 25px;
border-radius: 50%;
font-size: 1em;
background: blue;
color: white;
text-align: center;
top: -12px;
right: 5px;
}

View File

@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-nav-bar',
templateUrl: './nav-bar.component.html',
styleUrls: ['./nav-bar.component.scss']
})
export class NavBarComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB