So I have an idea for a little scrabble-like word game.
I have an array of strings such as
this.tilerows = [
['a', 'b', 'c', 'etc', ' '],
[' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' '], etc.
which I use to populate a grid of button items thus
<ion-row *ngFor="let list of tilerows; let i=index">
<ion-col *ngFor="let t of list;let j=index">
<button ion-button color="dark" outline (click)="tileClick(i,j)" class="tileButton">{{t}}</button>
<!--ion-item color="{{tilerowsStatus(i,j)}}" (click)="tileClick(i,j)" >
{{t}}
</ion-item-->
</ion-col>
</ion-row>
</ion-grid>
When any button on the grid is clicked the procedure tileClick(i,j) successfully updates the buttonâs string with the contents of this.tilerowsp[i][j]
What I want to do next is change the buttonâs color if it belongs to a correct answer (i.e. part of a legitimate word) before I ask scrabble fans in the family if it is at all fun to play. I can do the dictionary checking ok, but I havenât found a solution to change the color of the button.
Remnants of my attempt are in the commented out part of the code above. I made a second array of the same dimensions called tilerowsStatus with color strings in it thus:
this.tilerowsStatus = [
['primary','dark','dark','dark','dark'],
['dark','light','dark','dark','dark'],
['dark','dark','dark','dark','dark'],
But nothing I do in the html will make it change color. Iâve tried a few ideas from the forums but nothing is working - the other examples donât relate to arrays or ngFors.
Any ideas of links appreciated.