我为两个不同的动作设置了一个元素的style和ng-style,这是不起作用的。
如果我将两者加在一起,它就不起作用了。两者都是单独工作的
<div class="glyphicon glyphicon-heart" style="width:{{wide}}%;" ng-style="{'color': (istrue()) ? 'red' : 'yellow' }"></div>JS
$scope.wide = 50; // dynamic value
$scope.istrue = function () {
var abc = true;
if (abc) {
return true;
}
else {
return false;
}
}发布于 2019-01-28 18:11:52
您还可以通过添加动态类名来应用样式,如下所示:
HTML
<div class="glyphicon glyphicon-heart" style="width:78%;" ng-class="isArrabic()"></div>JS
$scope.wide = 78; // dynamic value
$scope.isArrabic = function () {
var arabic = true;
if (arabic) {
return 'floatRight';
}
else {
return 'floatLeft';
}
}CSS:
.floatRight {
float: right;
color: red;
}
.floatLeft {
float: left;
color: blue;
}https://stackoverflow.com/questions/54398782
复制相似问题