ng风格中的多个属性 [英] Multiple attributes in ng-style

查看:143
本文介绍了ng风格中的多个属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有多个原始样式属性,例如:

I need to have multiple raw style attributes like :

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

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

这不工作。在我使用

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

但不适用于IE。

推荐答案

ng-style等待对象字面量,因此您需要将您的代码调整为

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>

这篇关于ng风格中的多个属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆