sourcecode

ng-style의 다중 속성

copyscript 2023. 3. 5. 10:17
반응형

ng-style의 다중 속성

다음과 같은 raw style 속성을 여러 개 가질 필요가 있습니다.

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

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

이거 안 되네.사용할 때 동작합니다.

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

IE에는 해당되지 않습니다.

아래 보기 사용

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

ng-style은 오브젝트 리터럴을 대기하기 때문에 코드를 다음과 같이 조정해야 합니다.

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

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

언급URL : https://stackoverflow.com/questions/29435883/multiple-attributes-in-ng-style

반응형