Skip to content

Conversation

monpie3
Copy link
Owner

@monpie3 monpie3 commented Feb 2, 2023

No description provided.

@vercel
Copy link

vercel bot commented Feb 2, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
project-storefront-freshcart-bootstrap ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 2, 2023 at 7:09PM (UTC)
project-storefront-freshcart-bootstrap-wrx1 ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 2, 2023 at 7:09PM (UTC)

<!-- title -->
<h5 class="mb-3">Rating</h5>

<div class="form-check mb-2" *ngFor="let star_list of [].constructor(5); let i = index">
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

czy jest może jakiś ładniejszy sposób na to żeby wygenerować te gwiazdki?
wiem, że moglabym wrzucic tą 5 do zmiennej i byloby troche ladniej, ale chodzi mi o cos jeszcze bardziej poprawnego

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tak, można w ts zrobić np. tablicę obiektów, gdzie obiekt by miał dane potrzebne do prezentacji gwiazdki. Ciekawy sposób masz ale raczej tak nie robimy

)
.subscribe();

onCheckChange(event:Event) {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

czy jest może jakiś lepszy typ niż Event, tak żebym nie musiała póżniej zapisywać eventTarget jako HTMLInputElement?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

w zwykłym bootstrapowym checkbox chyba nie, tutaj ewentualnie dać typ 'any' zamiast Event, ale Twoje rozwiązanie na plus

W angular material jest event specjalny z którym jest dużo łatwiej

this.category,
this.sortBy$,
this.searchForm.valueChanges.pipe(startWith({ priceFrom: -1, priceTo: 9999999 })),
this.searchForm.valueChanges.pipe(startWith({ priceFrom: -1 })),
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

czemu właściwie muszę podać cokolwiek w startWith? jesli usune tez i priceFrom to przestaje mi sie wyswietlac lista

to dlatego że w 94 linijce w category-products.components.ts mam combineLatest i musi się wygenerować jakakolwiek wartość dla searchForm, żeby dostarczyło wszystkie elementy do combineLatest i przeszło dalej?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dokładnie tak, bez tego dane załadowałyby się dopiero po zmianach w formularzu np. dodaniu priceFrom

// find the unselected element
let i: number = 0;

formArray.controls.forEach((ctrl: AbstractControl) => {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tutaj w przykładzie było żeby ctrl oznaczyc jako FormControl, ale nie działało i musiałam użyć AbstractControl

https://stackoverflow.com/questions/40927167/angular-reactiveforms-producing-an-array-of-checkbox-values

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Przykład który podałaś jest sprzed 6 lat, to dużo jak na programowanie xd

możesz nie robić tego na forEach tylko znaleźć index za pomocą metody findIndex na formArray.controls i po tym indeksie usunąć element.

Zmienna 'let i' jest tutaj niepotrzebna, metoda forEach jako drugi parametr ma index elementu np.
formArray.controls.forEach((ctr: AbstractControl, idx) => { ... })

Nie jestem pewien, ale FormControl rozszerza AbstractControl, i tym może to być spowodowane co do typu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants