Arun Tyagi
Arun Tyagi

Reputation: 2256

attr.style is not working in angular2 rc1

I have upgraded from Angular2 beta to RC1

attr.style is not working properly, there is no error but this style is not coming

<div class="hotspot_info pointer" attr.style="top: {{towerPoint.posY}}%; left: {{towerPoint.posX}}%;" >

Upvotes: 1

Views: 63

Answers (3)

Rhushikesh
Rhushikesh

Reputation: 3700

import :

import {NgStyle} from '@angular/common';

set directive :

directives: [NgStyle]

then try:

<div class="hotspot_info pointer" [ngStyle]="{top: towerPoint.posY+'%'+; left: towerPoint.posX+'%'}" >

Upvotes: 2

Mahendra Kulkarni
Mahendra Kulkarni

Reputation: 1507

The ngStyle directive allows you to set CSS style

<div class="ng-style: expression;"> ... </div>

Upvotes: 0

Thierry Templier
Thierry Templier

Reputation: 202196

I would use the ngStyle directive instead:

<div class="hotspot_info pointer"
   [ngStyle]="{top: towerPoint.posY + '%', left: towerPoint.posX + '%'}" >

Upvotes: 2

Related Questions