BETTERZON-41: Added routing for product detail pages

This commit is contained in:
Patrick Müller 2020-12-03 11:31:48 +01:00
parent 38b20d28cb
commit 87193310a8
3 changed files with 15 additions and 9 deletions

View File

@ -8,7 +8,7 @@ import {ProductDetailPageComponent} from './product-detail-page/product-detail-p
const routes: Routes = [
{path: '', component: LandingpageComponent},
{path: 'product', component: ProductDetailPageComponent}
{path: 'product/:id', component: ProductDetailPageComponent}
];
@NgModule({

View File

@ -1 +1 @@
<p>product-detail-page works!</p>
<p>product-detail-page works! Product: {{productId}}</p>

View File

@ -1,4 +1,5 @@
import {Component, OnInit} from '@angular/core';
import {Router} from '@angular/router';
@Component({
selector: 'app-product-detail-page',
@ -6,8 +7,13 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./product-detail-page.component.css']
})
export class ProductDetailPageComponent implements OnInit {
productId: string;
constructor() { }
constructor(
private router: Router
) {
this.productId = router.url.substr(9, router.url.length);
}
ngOnInit(): void {
}