I am trying to give the style.marginTop.px property to my html by loading the value of an angular variable. Something like that:
Template:
<div class="map-container">
<div class="map">
<div class="marcador" [style.marginTop.px]="top" [style.marginLeft.px]="left"><b>X</b></div>
</div>
Components:
private moveTheMark(place: any): void {
switch(place) {
case '0':
this.top = '163px';
this.left = '420px';
break;
case '1':
this.top = '165px';
this.left = '467px';
break;
}
}
The moveTheMark function is called in the ngOnChanges and modifies the value of top and left based on the place parameter. However I can't get it to work. Any ideas?
You are using the style directive wrong, try removing the px something like this
You are adding too much px value to the directive