Answer the question
In order to leave comments, you need to log in
Angular 4 dynamic DOM change, style update issue?
Hello.
I am making a game in Angular. And I had a hitch with updating the styles for the added elements in the DOM.
import { Component, OnInit } from '@angular/core';
interface IUser {
balance: number
}
interface ICard {
number: number,
suit: number
}
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {
cardsExample: Array<ICard> = [{
number: 10,
suit: 2
},
{
number: 13,
suit: 1
}
];
cards = 20;
botCard = this.visualCard(this.cardsExample);
user: IUser = {
balance: 8000
}
constructor() { }
ngOnInit() {
}
private visualCard(card: Array<ICard>) {
let cardString = "";
card.forEach(element => {
cardString += "<img class=\"card\" style=\"height: 20vh;\" src=\"/assets/img/card/"+element.number+"."+element.suit+".png\">";
});
return cardString;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question