2015-04-03 7 views
18

Ich brauche Attribute wie mehrere rohe Stil haben:Mehrere Attribute in ng-Stil

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

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

Das funktioniert nicht. Es funktioniert, wenn ich

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

Aber nicht für IE verwenden.

Antwort

15

ng-Stil wartet auf eine Objektliteral, so müssen Sie Ihren Code

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

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

Nutzung auf Ansicht unten anpassen

<div ng-style="{ 
    'width': calc('100% -'+fixedColumnsWidth), 
    'margin-left': fixedColumnsWidth}"> 
Verwandte Themen