Multiple attributes in ng-style

前端 未结 2 995
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-17 07:15

I need to have multiple raw style attributes like :

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


        
相关标签:
2条回答
  • 2021-01-17 07:50

    ng-style waits for an object literal, so you need to adjust your code to

    $scope.css = {
     width: 'calc(100% -'+$scope.fixedColumnsWidth+')',
     'margin-left': $scope.fixedColumnsWidth
    }
    
    <div ng-style="css"></div>
    
    0 讨论(0)
  • 2021-01-17 08:04

    Use below on view

    <div ng-style="{
       'width': calc('100% -'+fixedColumnsWidth),
       'margin-left': fixedColumnsWidth}">
    
    0 讨论(0)
提交回复
热议问题