我已从Angular2 beta升级到RC1
attr.style工作不正常,没有错误,但这种风格不会出现
<div class="hotspot_info pointer" attr.style="top: {{towerPoint.posY}}%; left: {{towerPoint.posX}}%;" >
答案 0 :(得分:2)
我会改用ngStyle
指令:
<div class="hotspot_info pointer"
[ngStyle]="{top: towerPoint.posY + '%', left: towerPoint.posX + '%'}" >
答案 1 :(得分:2)
导入:
import {NgStyle} from '@angular/common';
set directive:
directives: [NgStyle]
然后尝试:
<div class="hotspot_info pointer" [ngStyle]="{top: towerPoint.posY+'%'+; left: towerPoint.posX+'%'}" >
答案 2 :(得分:0)
ngStyle指令允许您设置CSS样式
<div class="ng-style: expression;"> ... </div>