Вот что я попробовал:
export class AppComponent {
name = 'Angular';
items = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90];
mid = Math.round(this.items.length / 2);
selectedValue = undefined;
selected(param: string) {
this.selectedValue = param;
console.log('sth', this.selectedValue, this.mid);
}
}
<!-- html -->
<div class="scrollmenu">
<a *ngFor="let a of items; let i = index" (click)="selected(a)"
[ngStyle]="{order: a === selectedValue ? mid : i}"
>
{{a}}
</a>
</div>
<!-- css -->
div.scrollmenu {
background-color: #333;
overflow: auto;
white-space: nowrap;
display: flex;
flex-direction: row;
}
div.scrollmenu a {
/* display: inline-block; */
color: white;
text-align: center;
padding: 14px;
text-decoration: none;
}
div.scrollmenu a:hover {
background-color: #777;
}
ref: https://stackblitz.com/edit/angular-bdmc95