Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit b760280

Browse files
DeborahKDeborahK
DeborahK
authored and
DeborahK
committed
Update to guard to match course
1 parent e57d2d4 commit b760280

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

APM-Final/src/app/products/product-detail.guard.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ export class ProductDetailGuard implements CanActivate {
1010
constructor(private router: Router) { }
1111

1212
canActivate(
13-
next: ActivatedRouteSnapshot,
13+
route: ActivatedRouteSnapshot,
1414
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
15-
const id = +next.url[1].path;
16-
// const id2 = next.paramMap.get('id');
17-
// console.log(id2);
15+
const id = Number(route.paramMap.get('id'));
1816
if (isNaN(id) || id < 1) {
1917
alert('Invalid product Id');
2018
this.router.navigate(['/products']);

APM-Final/src/app/products/product.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class ProductService {
1818
getProducts(): Observable<IProduct[]> {
1919
return this.http.get<IProduct[]>(this.productUrl)
2020
.pipe(
21-
tap(data => console.log('All: ' + JSON.stringify(data))),
21+
tap(data => console.log('All: ', JSON.stringify(data))),
2222
catchError(this.handleError)
2323
);
2424
}

0 commit comments

Comments
 (0)