Skip to content
Snippets Groups Projects
Commit b7602806 authored by DeborahK's avatar DeborahK
Browse files

Update to guard to match course

parent e57d2d46
No related branches found
No related tags found
No related merge requests found
......@@ -10,11 +10,9 @@ export class ProductDetailGuard implements CanActivate {
constructor(private router: Router) { }
canActivate(
next: ActivatedRouteSnapshot,
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
const id = +next.url[1].path;
// const id2 = next.paramMap.get('id');
// console.log(id2);
const id = Number(route.paramMap.get('id'));
if (isNaN(id) || id < 1) {
alert('Invalid product Id');
this.router.navigate(['/products']);
......
......@@ -18,7 +18,7 @@ export class ProductService {
getProducts(): Observable<IProduct[]> {
return this.http.get<IProduct[]>(this.productUrl)
.pipe(
tap(data => console.log('All: ' + JSON.stringify(data))),
tap(data => console.log('All: ', JSON.stringify(data))),
catchError(this.handleError)
);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment