from @art-lowel: create array and map all options to it
I created a list in the component that contains all the possible values a button or an option in the select can have, that way we can get rid of those *ngIfs in the template, and render everything with an *ngFor Instead of putting all the data needed to select an option and to redirect to the correct option in the template, I created an interface to represent all the info we need: ComColPageNavOption During ngOnInit, I first take the browseBy types in the config, and perform a map operation on them, that basically means, turn every element of this array in to something else using the function inside the map operator. So inside the map function I each BrowseByTypeConfig object in to a ComColPageNavOption object Afterwards I check whether we're dealing with a collection or a community, and in each case I create a ComColPageNavOption object, and add it to the front of the allOptions array ...this.allOptions means enumerate everything that's currently in the allOptions array, so I put my new object first, then enumerate everything that was already there, and assign the result again to this.allOptions
Showing
- src/app/shared/comcol-page-browse-by/comcol-page-browse-by.component.html 1 addition, 28 deletions...omcol-page-browse-by/comcol-page-browse-by.component.html
- src/app/shared/comcol-page-browse-by/comcol-page-browse-by.component.ts 33 additions, 1 deletion.../comcol-page-browse-by/comcol-page-browse-by.component.ts
Please register or sign in to comment