I have completed the implementation of all UI components, which are visually appealing.
https://i.sstatic.net/hxJQr.png
Here is the data structure I am using:
public filters = [
{
tag: 'Year',
label: 'year',
items: [2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020]
},
{
tag: 'Cash On Delivery',
label: 'cash',
items: this.truthyFalsy
},
{
tag: 'In stock',
label: 'stock',
items: this.truthyFalsy
}
];
Below is a snippet of my HTML code:
<div *ngFor="let filter of filters">
<p ><small>{{filter?.tag}}</small></p>
<div class="line"></div>
<div>
<div class="item" *ngFor="let item of filter?.items">
<button class="btn" [ngClass]="{'btn-active-1':labelType1 === filter.label && selectedItem === item }"
(click)="select(item,filter?.label)">{{item}}</button>
</div>
</div>
</div>
The goal is to make the selected buttons active. Here are the specific requirements:
- In the
year section
, only one button should be active. - In the
Cash On Delivery
section, only one button should be active. - In the
In stock
section, only one button should be active.
Each section must have at least one active button using ngClass
.