2015-04-03 15 views
18

muszę mieć wiele atrybutów stylu surowego jak:Wiele atrybutów w ng stylu

$scope.css = "'width': 'calc(100% - "+$scope.fixedColumnsWidth+"'),'margin-left':'"+ $scope.fixedColumnsWidth+"'"; 

<div ng-style="{css}"> 

to nie działa. Działa, gdy używam

<div style="{{css}}"> 

Ale nie dla IE.

Odpowiedz

15

ng stylu czeka na obiekcie dosłownym, więc trzeba dostosować swój kod do

$scope.css = { 
width: 'calc(100% -'+$scope.fixedColumnsWidth+')', 
'margin-left': $scope.fixedColumnsWidth 
} 

<div ng-style="css"></div> 
19

użytkowania poniżej na widok

<div ng-style="{ 
    'width': calc('100% -'+fixedColumnsWidth), 
    'margin-left': fixedColumnsWidth}"> 
Powiązane problemy