-
Notifications
You must be signed in to change notification settings - Fork 10
Templates sock reviews #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { AsyncPipe, NgFor } from '@angular/common'; | ||
import { Component } from '@angular/core'; | ||
import {Component, Input} from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
import { SocksService } from './socks.service'; | ||
import { Review } from './sock.model'; | ||
|
@@ -11,11 +11,16 @@ import { Review } from './sock.model'; | |
templateUrl: './sock-reviews.component.html' | ||
}) | ||
export class SockReviewsComponent { | ||
@Input() sockId!: number | undefined; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Het Aangezien je hier undefined ook accepteert
|
||
reviews$!: Observable<Review[]>; | ||
|
||
constructor(private socksService: SocksService) {} | ||
|
||
ngOnInit(): void { | ||
this.reviews$ = this.socksService.getLatestReviews(); | ||
if(this.sockId){ | ||
this.reviews$ = this.socksService.getSockReviews(this.sockId); | ||
} else { | ||
this.reviews$ = this.socksService.getLatestReviews(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,7 @@ <h1 style="margin-top: 25px;">{{ sock.name }}</h1> | |
</div> | ||
</section> | ||
|
||
|
||
<app-sock-reviews [sockId]="this.sockId"></app-sock-reviews> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fyi :: in de template kan je de |
||
|
||
<section class="contact_section" style="margin-bottom: 36px"> | ||
<div class="container px-0"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,22 +3,24 @@ import { Observable } from 'rxjs'; | |
import { Sock } from './sock.model'; | ||
import { SocksService } from './socks.service'; | ||
import { AsyncPipe, NgIf, TitleCasePipe } from '@angular/common'; | ||
import { SockReviewsComponent } from "./sock-reviews.component"; | ||
|
||
@Component({ | ||
selector: 'app-sock', | ||
standalone: true, | ||
imports: [NgIf, AsyncPipe, TitleCasePipe], | ||
imports: [NgIf, AsyncPipe, TitleCasePipe, SockReviewsComponent], | ||
templateUrl: './sock.component.html' | ||
}) | ||
export class SockComponent { | ||
sock$!: Observable<Sock>; | ||
sockId: number | undefined; | ||
|
||
constructor(private socksService: SocksService) {} | ||
|
||
ngOnInit(): void { | ||
// HACK: This is not the way to get the sockId!! | ||
const sockId = +window.location.pathname.split('/')[2]; | ||
this.sock$ = this.socksService.getById(sockId); | ||
this.sockId = +window.location.pathname.split('/')[2]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probeer fields altijd te vermijden. Een van de oefeningen is "Maak een next button om naar de volgende sock te gaan" Je kan vb met een getter werken: get sockId(): number {
return +window.location.pathname.split('/')[2];
} (maar natuurlijk is die window.location NOT the Angular way to go! (nog een andere oefn;) |
||
this.sock$ = this.socksService.getById(this.sockId); | ||
} | ||
|
||
buy(): void { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ATTENTION:
Heb je de network tab in de gaten gehouden?
Ben je hier 2x de reviews aan het ophalen?