In my Angular app in my component.html I have a game board displayed by iteration of i
and j
:
<div class="board text-center">
<div
class="boardRow"
*ngFor="
let row of this.boards[this.clientsPlayerNumber];
let i = index
"
>
<div *ngFor="let box of row; let j = index">
<div
class="boardCell"
[style.backgroundColor]="box.color"
#cell
></div>
</div>
</div>
</div>
Is there a chance to get in my component.ts any HTMLElement
of this board cell, when not having interaction (events) in the view, but having only i
and j
in the component.ts?
Later on I want to use it to display animation having HTMLElement
:
...
this.animateSprite(true, someViewElementHavingIandJ);
...
private animateSprite(isHit: boolean, ref: HTMLElement): void {
this.displaySprite = true;
this.spriteX = ref.offsetLeft - 50;
this.spriteY = ref.offsetTop - 50;
this.spriteUrl = isHit
? 'https://i.ibb.co/H4f84Wn/explode.png'
: 'https://i.ibb.co/c3WLWN1/splash.png';
}
Can I combine somehow #cell
with i
and j
in the view, to use it later on as a @ViewChild('cell-i-j', { static: true }) cell-i-j: ElementRef;
?