Is there a way to include button in this code which will with click make the same change to an array the same way [ngStyle] does in the following part of the code?
app.component.html
<div class="styling">
<ul>
<li *ngFor = "let a of arr"
[ngStyle]="changeFont()">
{{a}}
</li>
</ul>
</div>
app.component.ts
arr=['car','house','beach','microphone'];
changeFont(){
return {'font-size.px':15}
}
In Angular you has variables in .ts, and use this variables in the .html.
An example
You can use
And see how change the style
As you has "severals"
<li>you need severals variables if you want severals<li>can be "selected" at time or an unique variable if only one<li>can be selected at time.The "severals variables" are an Array, so to change one element of the array you need pass the "index" of the array
The unique variable is a number that is the "index" selected. For no selected index, the variable becomes -1 (Remember that 0 is the fisrt element of the array)