X-Git-Url: https://juplo.de/gitweb/?p=examples%2Fangular-tutorial;a=blobdiff_plain;f=src%2Fapp%2Fproduct-details%2Fproduct-details.component.ts;fp=src%2Fapp%2Fproduct-details%2Fproduct-details.component.ts;h=049b7cc8be6b2ef74c1f245ad2391a98a407be81;hp=0000000000000000000000000000000000000000;hb=bfe15f71205934d62304ce869cb81aeaec551593;hpb=951fb792a342f38bea1760c5104e9f844ac7d49c diff --git a/src/app/product-details/product-details.component.ts b/src/app/product-details/product-details.component.ts new file mode 100644 index 0000000..049b7cc --- /dev/null +++ b/src/app/product-details/product-details.component.ts @@ -0,0 +1,21 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { products } from '../products'; + +@Component({ + selector: 'app-product-details', + templateUrl: './product-details.component.html', + styleUrls: ['./product-details.component.css'] +}) +export class ProductDetailsComponent implements OnInit { + product; + + constructor(private route: ActivatedRoute) { } + + ngOnInit() { + this.route.paramMap.subscribe(params => { + this.product = products[+params.get('productId')]; + }); + } + +}