diff --git a/client/src/app/app-routing.module.ts b/client/src/app/app-routing.module.ts
index 0297262..d32c9b3 100644
--- a/client/src/app/app-routing.module.ts
+++ b/client/src/app/app-routing.module.ts
@@ -1,7 +1,15 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
+import { HomeComponent } from './home/home.component';
+import { ProductDetailsComponent } from './shop/product-details/product-details.component';
+import { ShopComponent } from './shop/shop.component';
+
+const routes: Routes = [
+ {path: '', component: HomeComponent},
+ {path: 'shop', loadChildren: ()=> import('./shop/shop.module').then(mod => mod.ShopModule)},
+ {path: '**', redirectTo: '', pathMatch: 'full'}
+];
-const routes: Routes = [];
@NgModule({
imports: [RouterModule.forRoot(routes)],
diff --git a/client/src/app/app.component.html b/client/src/app/app.component.html
index 10b48c1..c8a3fba 100644
--- a/client/src/app/app.component.html
+++ b/client/src/app/app.component.html
@@ -1,4 +1,4 @@
diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts
index 3bd3175..e449f23 100644
--- a/client/src/app/app.module.ts
+++ b/client/src/app/app.module.ts
@@ -7,6 +7,7 @@ import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { CoreModule } from './core/core.module';
import { ShopModule } from './shop/shop.module';
+import { HomeModule } from './home/home.module';
@NgModule({
declarations: [
@@ -18,7 +19,7 @@ import { ShopModule } from './shop/shop.module';
BrowserAnimationsModule,
HttpClientModule,
CoreModule,
- ShopModule
+ HomeModule
],
providers: [],
bootstrap: [AppComponent]
diff --git a/client/src/app/core/core.module.ts b/client/src/app/core/core.module.ts
index 64a61b4..e748d8b 100644
--- a/client/src/app/core/core.module.ts
+++ b/client/src/app/core/core.module.ts
@@ -1,13 +1,15 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { NavBarComponent } from './nav-bar/nav-bar.component';
+import { RouterModule } from '@angular/router';
@NgModule({
declarations: [NavBarComponent],
imports: [
- CommonModule
+ CommonModule,
+ RouterModule
],
exports: [NavBarComponent]
})
diff --git a/client/src/app/core/nav-bar/nav-bar.component.html b/client/src/app/core/nav-bar/nav-bar.component.html
index f7e16f4..e2ab019 100644
--- a/client/src/app/core/nav-bar/nav-bar.component.html
+++ b/client/src/app/core/nav-bar/nav-bar.component.html
@@ -1,9 +1,9 @@
\ No newline at end of file
+
diff --git a/client/src/app/core/nav-bar/nav-bar.component.scss b/client/src/app/core/nav-bar/nav-bar.component.scss
index e61ee7d..1af87aa 100644
--- a/client/src/app/core/nav-bar/nav-bar.component.scss
+++ b/client/src/app/core/nav-bar/nav-bar.component.scss
@@ -9,4 +9,20 @@
text-align: center;
top: -12px;
right: 5px;
-}
\ No newline at end of file
+}
+
+a {
+ text-decoration: none;
+ color: #343a40;
+
+ &.active {
+ color: orange;
+ }
+}
+
+.logo {
+ cursor: pointer;
+ &:focus{
+ outline: none;
+ }
+}
diff --git a/client/src/app/home/home.component.html b/client/src/app/home/home.component.html
new file mode 100644
index 0000000..5f2c53f
--- /dev/null
+++ b/client/src/app/home/home.component.html
@@ -0,0 +1 @@
+home works!
diff --git a/client/src/app/home/home.component.scss b/client/src/app/home/home.component.scss
new file mode 100644
index 0000000..e69de29
diff --git a/client/src/app/home/home.component.ts b/client/src/app/home/home.component.ts
new file mode 100644
index 0000000..73acf06
--- /dev/null
+++ b/client/src/app/home/home.component.ts
@@ -0,0 +1,15 @@
+import { Component, OnInit } from '@angular/core';
+
+@Component({
+ selector: 'app-home',
+ templateUrl: './home.component.html',
+ styleUrls: ['./home.component.scss']
+})
+export class HomeComponent implements OnInit {
+
+ constructor() { }
+
+ ngOnInit(): void {
+ }
+
+}
diff --git a/client/src/app/home/home.module.ts b/client/src/app/home/home.module.ts
new file mode 100644
index 0000000..25d40d4
--- /dev/null
+++ b/client/src/app/home/home.module.ts
@@ -0,0 +1,16 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { HomeComponent } from './home.component';
+
+
+
+@NgModule({
+ declarations: [
+ HomeComponent
+ ],
+ imports: [
+ CommonModule
+ ],
+ exports: [HomeComponent]
+})
+export class HomeModule { }
diff --git a/client/src/app/shop/product-details/product-details.component.html b/client/src/app/shop/product-details/product-details.component.html
new file mode 100644
index 0000000..b2afd31
--- /dev/null
+++ b/client/src/app/shop/product-details/product-details.component.html
@@ -0,0 +1,22 @@
+
+
+

+
+
+
{{product.name}}
+
{{product.price | currency}}
+
+
+ 2
+
+
+
+
+
+
+
Description
+
{{product.description}}
+
+
+
+
diff --git a/client/src/app/shop/product-details/product-details.component.scss b/client/src/app/shop/product-details/product-details.component.scss
new file mode 100644
index 0000000..e69de29
diff --git a/client/src/app/shop/product-details/product-details.component.ts b/client/src/app/shop/product-details/product-details.component.ts
new file mode 100644
index 0000000..05289ae
--- /dev/null
+++ b/client/src/app/shop/product-details/product-details.component.ts
@@ -0,0 +1,30 @@
+import { Component, OnInit } from '@angular/core';
+import { ActivatedRoute } from '@angular/router';
+import { IProduct } from 'src/app/shared/models/product';
+import { ShopService } from '../shop.service';
+
+@Component({
+ selector: 'app-product-details',
+ templateUrl: './product-details.component.html',
+ styleUrls: ['./product-details.component.scss']
+})
+export class ProductDetailsComponent implements OnInit {
+ product: IProduct;
+
+ constructor(private shopService: ShopService, private activatedRoute: ActivatedRoute) { }
+
+ ngOnInit(): void {
+ this.loadProduct();
+ }
+
+ loadProduct(){
+ this.shopService.getProduct(+this.activatedRoute.snapshot.paramMap.get('id')).subscribe(
+ {
+ next: (product) => { this.product = product; },
+ error: (e: any) => { console.log(e); },
+ complete: () => { console.log('complete'); }
+ }
+ );
+ }
+
+}
diff --git a/client/src/app/shop/product-item/product-item.component.html b/client/src/app/shop/product-item/product-item.component.html
index 426b225..b1391b3 100644
--- a/client/src/app/shop/product-item/product-item.component.html
+++ b/client/src/app/shop/product-item/product-item.component.html
@@ -1,13 +1,13 @@
diff --git a/client/src/app/shop/shop-routing.module.ts b/client/src/app/shop/shop-routing.module.ts
index 570746c..adb709a 100644
--- a/client/src/app/shop/shop-routing.module.ts
+++ b/client/src/app/shop/shop-routing.module.ts
@@ -1,12 +1,19 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
+import { RouterModule, Routes } from '@angular/router';
+import { ShopComponent } from './shop.component';
+import { ProductDetailsComponent } from './product-details/product-details.component';
-
+const routes: Routes = [
+ {path: '', component: ShopComponent},
+ {path: ':id', component: ProductDetailsComponent},
+]
@NgModule({
declarations: [],
imports: [
- CommonModule
- ]
+ RouterModule.forChild(routes)
+ ],
+ exports: [RouterModule]
})
export class ShopRoutingModule { }
diff --git a/client/src/app/shop/shop.module.ts b/client/src/app/shop/shop.module.ts
index 4e017c3..235a260 100644
--- a/client/src/app/shop/shop.module.ts
+++ b/client/src/app/shop/shop.module.ts
@@ -3,18 +3,21 @@ import { CommonModule } from '@angular/common';
import { ShopComponent } from './shop.component';
import { ProductItemComponent } from './product-item/product-item.component';
import { SharedModule } from '../shared/shared.module';
+import { ProductDetailsComponent } from './product-details/product-details.component';
+import { ShopRoutingModule } from './shop-routing.module';
@NgModule({
declarations: [
ShopComponent,
- ProductItemComponent
+ ProductItemComponent,
+ ProductDetailsComponent
],
imports: [
CommonModule,
- SharedModule
- ],
- exports: [ShopComponent]
+ SharedModule,
+ ShopRoutingModule
+ ]
})
export class ShopModule { }
diff --git a/client/src/app/shop/shop.service.ts b/client/src/app/shop/shop.service.ts
index 8ff943c..ff7ffc6 100644
--- a/client/src/app/shop/shop.service.ts
+++ b/client/src/app/shop/shop.service.ts
@@ -5,6 +5,7 @@ import { IPagination } from '../shared/models/pagination';
import { IType } from '../shared/models/producttype';
import { map } from 'rxjs/operators'
import { ShopParams } from '../shared/models/shopparams';
+import { IProduct } from '../shared/models/product';
@Injectable({
providedIn: 'root'
@@ -41,6 +42,10 @@ export class ShopService {
);
}
+ getProduct(id: number){
+ return this.http.get(this.baseURL + 'products/' + id);
+ }
+
getBrands(){
return this.http.get(this.baseURL + 'products/brands');
}