I need to create a component which takes any number of links <a>link</a> and structure the design into two groups.
- first 2 or 3 links (based on an input parameter) visible inline.
- second group should be in a menu.
I solved the issue by creating a class that contains all the needed parameters, then separating the list of links into two separate arrays, and by using ngIf I managed to get the results, but the code does not look clean, and harder to use.
What I'm trying to achieve is something like below: custom component:
@Component({
selector: 'my-dynamic-links',
templateUrl: './custom-component.html'
})
CustomComponent {
@Input() noOfVisibleLinks: number;
}
parent html
<my-dynamic-links noOfVisibleLinks="3">
<a class="btn btn-primary" href="#" role="button">Link 1</a>
<a class="btn btn-primary" href="#" role="button">Link 2</a>
<a class="btn btn-primary" href="#" role="button">Link 3</a>
<a class="btn btn-primary" href="#" role="button">Link 4</a>
<a class="btn btn-primary" href="#" role="button">Link 5</a>
<a class="btn btn-primary" href="#" role="button">Link 6</a>
<a class="btn btn-primary" href="#" role="button">Link 7</a>
</my-dynamic-links>
it should look like this:
